How to Partition & Format Drives During Windows Autopilot Deployment?
Updated: Jan 12
Assume your machine has only one physcial drive and you want to create the partition and format the partition during Windows Autopilot, here is the powershell script.
# Resize-CDrive.ps1
# Load required moduleImport-Module Storage
# Get the C drive volume
$volume = Get-Partition -DriveLetter C | Get-Volume
# Resize the volume to 90GB (adjust size as needed)
Resize-Partition -DriveLetter $volume.DriveLetter -Size 90GB
# List all disks to identify the one with unallocated space
Get-Disk
$diskNumber = 0
# Get the disk object
$disk = Get-Disk -Number
$diskNumber
# Create a new partition on the unallocated space
$partition = New-Partition -DiskNumber $diskNumber -UseMaximumSize -AssignDriveLetter
# Format the new partition with NTFS file system and label it
Format-Volume -Partition $partition -FileSystem NTFS -NewFileSystemLabel "NewVolume" -Confirm:$false
# Optionally, you can assign a specific drive letter if needed
# $partition | Set-Partition -NewDriveLetter E

Note: Even if you reset your machine keeping this script autopilot, the creation of partition will fail as you already have partition on the machine. Also, the format command will not format the other partition. But if you are planning to re-use the machine and hand over to new person then manually you will have to format the other drive.






Comments