How to Partition and Format a Drive Using PowerShell

You can use PowerShell to partition and format drives on Windows 10 thanks to its extensive options. So, here’s how you can prepare a drive for new data using PowerShell on Windows 10.

1. Open PowerShell and Get-Disk

Open PowerShell and select the disk you want to format and partition. In the following examples, I’m using a 128GB USB flash drive, but the commands and processes apply to any drive.

Input powershell in your Start menu search bar, then right-click the Best Match and select Run as administrator.

Now, input get-disk and press Enter to generate a list of currently accessible disks.

The get-disk command brings up a list of every disk on your computer, along with its name, drive status, total size, and partition type.

MBR or GPT?

You might have noticed the two different partition styles commonly used for Windows systems: MBR and GPT.

In short, MBR only allows for four total partitions on the drive, while GPT allows up to 128 partitions. On my tiny example USB flash drive, this doesn’t make much difference, but you might want to split a larger drive into small partitions for data management and so on.

For most modern drives, working with modern operating systems, GPT is the way to go. It can handle larger drives, more partitions, and is less prone to error.

If you decide you want to convert your GPT disk to an MBR, check out our MBR to GPT no data loss conversion guide.

2. Choose a Disk and Clear Data Using Clear-Disk

Now you have a list of disks, you can select the one you want to format and partition. You can select and format at the disk using the following command:

Replace number x with the number of the disk you want to clear, then press Enter to run the command.

3. Create a New Partition, Format the Volume, and Add a Drive Letter

The next step is to create a new partition. In this case, we’re going to create a single partition covering the entire drive, then format the volume using the NTFS file system and give the newly created volume a name. As ever, switch the disk number for your own, and you can change the new file system label to something of your choosing.

After formatting the volume and adding a new name, you can assign a new drive letter using the following command:

Again, switch out your disk number, and add the drive letter of your choice, avoiding conflicts with existing drives. That’s it: your drive is ready for use.

Creating Multiple Partitions or Partitions of Different Sizes

Say you don’t want one massive partition on your drive. You might want to break your drive up into smaller partitions for different types of data or content. If that’s the case, you have a few different options.

For example, to create one partition of a specific size and another partition to fill the remaining space, use the following commands:

Note the differences between the two commands. Each command uses a different drive letter, while the second command uses the $MaxSize variable to create a partition using the remaining space on the drive.

After you enter each command, Windows will open the newly created partition with the drive letter you assign.

You can check the status of your partitions using the following command:

How to Resize a Partition Using PowerShell

You can use PowerShell to resize a drive partition, too. This command is handy if you want to shrink or extend a partition, but it does depend on how much remaining space is available.

Remember, you cannot extend a partition into a space that doesn’t exist or is already occupied. If your drive is already at maximum capacity, i.e., every gigabyte is accounted for in an existing partition, you’ll have to make more changes.

Furthermore, if the drive you’re attempting to shrink is at capacity, e.g., is completely full of data, you’ll have to delete or move files to accommodate the partition changes.

First up, use the get-partition command from the previous section to identify the partition number or drive letter for the partition you wish to resize.

In my example, I’ve downsized the larger partition on my USB flash drive from around 90GB to 50GB.

How to Change Your Drive Letter Using PowerShell

The final small PowerShell drive formatting command to learn is to change your drive letter. Switching out your drive letter for another isn’t always necessary, but it can be handy for when you want to rearrange your drives for easier management or otherwise.

Enter the existing drive letter first, followed by the drive letter you want to switch to.

To confirm, you can run the get-partition -disknumber command from the previous section. Also, Windows will open the respective drive under its new letter, confirming the change.

Other Ways to Manage Drives on Windows 10

PowerShell is just one way you can manage your drives in Windows 10. Another option is to use the DiskPart command-line utility, which is available in Command Prompt and PowerShell.

Then there’s the Disk Management utility in Windows 10 itself, not to mention power third-party software such as Partition Master or the extensive functionality of the Linux distro, GParted.

In short, Windows 10 users have an extensive range of options when it comes to managing storage.