top of page
Search

How to Partition & Format Drives During Windows Autopilot Deployment?

May 28, 2024
1 min read

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


# Replace 0 with the Disk Number you want to format

$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

Rated 0 out of 5 stars.
No ratings yet

Add a rating

Disclaimer: The above content is created at Tek-Doyen's sole discretion. Razorpay shall not be liable for any content provided here and shall not be responsible for any claims and liability that may arise due to merchant’s non-adherence to it.

bottom of page