MDT 2013 TS: How to shrink the Windows partition by a specific size instead of a percentage?

Arthur Durand 166 Reputation points
2021-07-22T08:25:37.327+00:00

MDT 2013 task sequence: How to shrink the Windows partition by a specific size instead of a percentage

I need to figure out a way to shrink the WIndows partition by a specific size instead of a percentage in the MDT 2013 task sequence so that I can create a recovery partition with a specific size!

I was thinking of letting the task sequence create the System, MSR and Windows partition and using a custom script to shrink and create the recovery partition by and to a specific size! However, I've already added a VBS script to allow me to select the default disk to use during the Format and Create partitions in the task sequence! The VBS script basicallly just changes the TargetDisk value based on the Disk number I select! I have no experience in writing or editing VBS and would like some adivce! What would be the easiest way to achieve the specific size Recovery partition, still allowing me to select TargetDisk during deployment?

Any advice would be highly appreciated

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,591 questions
Microsoft Deployment Toolkit
Microsoft Deployment Toolkit
A collection of Microsoft tools and documentation for automating desktop and server deployment. Previously known as Microsoft Solution Accelerator for Business Desktop Deployment (BDD).
894 questions
0 comments No comments
{count} votes

Accepted answer
  1. Arthur Durand 166 Reputation points
    2021-07-23T09:12:25.643+00:00

    I ended up deleteing the Recovery partition from the MDT Task Seuence, setting the Windows partition to use 100% of the remaining disk space! I then added powershell and diskpart scripts after the partition and format task sequence to resize the Windows partition by 1GB and to create the Recovery partition!

    Sample of my powershell script (CreateRecoveryPartition-UEFI.ps1):
    $OSDiskNumber = Get-Volume | Where {$_.FileSystemLabel -eq "Windows"} | Get-Partition | Get-Disk | Select Number

    If (0 -eq ($OSDiskNumber.Number))
    {
        diskpart /s $env:ScriptRoot\CreateRecoveryPartition-UEFI.txt
    }
    If (1 -eq ($OSDiskNumber.Number))
    {
        diskpart /s $env:ScriptRoot\CreateRecoveryPartition-D1-UEFI.txt
    }
    

    CreateRecoveryPartition-UEFI.txt
    rem == CreateRecoveryPartitions-UEFI.txt ==
    select disk 0
    select partition 3
    rem == b. Create space for the recovery tools
    shrink minimum=1000
    rem ** NOTE: Update this size to match the
    rem size of the recovery tools
    rem (winre.wim) **
    rem === Create Recovery partition ======================
    create partition primary
    format quick fs=ntfs label="Recovery"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    list volume
    exit

    CreateRecoveryPartition-D1-UEFI
    rem == CreateRecoveryPartitions-UEFI.txt ==
    select disk 1
    select partition 3
    rem == b. Create space for the recovery tools
    shrink minimum=1000
    rem ** NOTE: Update this size to match the
    rem size of the recovery tools
    rem (winre.wim) **
    rem === Create Recovery partition ======================
    create partition primary
    format quick fs=ntfs label="Recovery"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    list volume
    exit

    My scripts makes provision for cases where there's a hard drive and SSD isntalled and the SSD is listed as Disk 1. I also run a custom script before the Partition and Format task sequense to detect the SSD and to set that as the Target OS Disk


1 additional answer

Sort by: Most helpful
  1. XinGuo-MSFT 18,081 Reputation points
    2021-07-23T06:56:17.05+00:00

    Hi,

    We could resizing partition with DiskPart using desired and minimum options.

    https://learn.microsoft.com/en-us/windows-server/storage/disk-management/shrink-a-basic-volume

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.