Manage Disk Partitions with Windows PowerShell

Print View Mobile View

In this post I will show you how to view the list of existing partitions in Windows, delete an existing partition, create a new disk partition, and more using Windows PowerShell.

View Disk and Existing Partitions

This command will give you a list of existing partitions, their drive letters, and the disk they are associated with:

Get-Disk | Get-Partition

The information we get here is used later for deleting or creating a new partition.

Delete a Partition

To remove a partition from a specific disk, the Remove-Partition function is used. When using this function, you need to specify the disk number and the partition number. This is where information from our first command comes useful.

Remove-Partition -DiskNumber 1 -PartitionNumber 1

When you execute the command, you’ll get a prompt to confirm your action. To silently execute it, use the –confirm parameter with $false as value, like so:

Remove-Partition -DiskNumber 1 -PartitionNumber 1 -Confirm:$false

Create a Partition

To create a new partition, the New-Partition function is used. The minimum parameters this function requires are the disk number and the size of the partition. To specify the exact size, use -Size parameter with desired size as value:

New-Partition -DiskNumber 1 -Size 1GB #Available unit values: bytes, KB, MB, GB, TB

Or to use the entire available space, use -UseMaximumSize parameter:

New-Partition -DiskNumber 1 -UseMaximumSize #Use entire available space

You can also assign a specific drive letter to the new partition if you want:

New-Partition -DiskNumber 1 -UseMaximumSize -DriveLetter S

Or, automatically assign an available drive letter:

New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter

Format Partition

Now that you’ve created the partition, it needs to be formatted to be usable. To do that, Format-Volume is used.

Format-Volume -DriveLetter S -FileSystem FAT32 -NewFileSystemLabel SumTips #Optional parameter: -FullFormat


Get-Partition -DiskNumber 1 -PartitionNumber 1 | Format-Volume -FileSystem FAT32 -NewFileSystemLabel SumTips

Above I have used the FAT32 file system. Available file system types are: NTFS, ReFS, exFAT, FAT32, and FAT.

-NewFileSystemLabel can be used if you want to assign a label to the partition.

Resize Partition

Resize-Partition can help you out if you wanted to shrink or extend a partition:

Get-Partition -DriveLetter S | Resize-Partition -Size 50GB

More Options:

Change Partition Drive Letter

Set-Partition -DriveLetter S -NewDriveLetter T

Remove a Partition

Remove-Partition -DriveLetter S

Set/Remove Readonly flag

Set-Disk 1 -isReadOnly $true # $false to disable