Drive set up

How to format a hard drive using PowerShell on Windows 10

Did you get a new hard drive or trying to get rid of one? Here are the steps to format it using PowerShell.

Format hard drive using PowerShell on Windows 10

When setting up a new hard drive on Windows 10, you need to format it to properly delete any data and configure a compatible file system to allow the OS to read and write data on the drive.

You may also want to consider formatting a drive to wipe out any of your personal files to prevent someone else getting a hold of your files when getting rid of a drive.

Although it might sound like a tedious process, it’s not, and Windows 10, similar to previous versions, includes a number of ways to quickly format a drive, including using PowerShell.

In this guide, you’ll learn the steps to use PowerShell commands to format a hard drive on Windows 10, whether it’s a new drive or you simply want to delete everything and start over.

How to format a hard drive using PowerShell

The process to format a drive and get it ready to store data is straightforward. Just make sure to understand that going through these steps will erase everything stored in the drive. 

Use these steps to format a hard drive using PowerShell commands on Windows 10:

  1. Open Start.

  2. Search for Windows PowerShell, right-click the result, and select the Run as administrator option.

  3. Type the following command to identify the hard drive you want to repair and press Enter:

    Get-Disk
  4. Type the following command to clean the drive and press Enter:

    Get-Disk 1 | Clear-Disk -RemoveData

    In the above command, make sure to change 1 with the disk number of the drive you want to format. If you specify the number incorrectly, you could end up wiping out the wrong drive causing data loss.

  5. Type Y to confirm that you want to wipe the specified drive and press Enter.

  6. Type the following command to initialize the disk with the default GUID Partition Table (GPT) partition scheme and press Enter:

    Initialize-Disk -Number 1

    In the above command, make sure to change 1 with the disk number of the drive you want to format.

    Important: Although it’s recommended to use a GPT partition scheme, if required, you can use the Master Boot Record (MBR) scheme using this command: Initialize-Disk -Number 1 -PartitionStyle MBR.
  7. Type the following command to create a new partition using the NTFS file system, assign a name for the drive, and press Enter:

    New-Partition -DiskNumber 1 -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel myDrive

    In the above command, make sure to change 1 with the disk number of the drive you want to format, and change myDrive with the name you want to use for the storage.

  8. Type the following command to assign a drive letter to the USB drive and press Enter:

    Get-Partition -DiskNumber 1 | Set-Partition -NewDriveLetter G

    In the above command, make sure to change 1 with the disk number of the drive you want to format, and change G with the letter you want to assign to the storage. If you get the “Set-Partition : The requested access path is already in use.” error message, run the command one more time or specify another driver letter.

    PowerShell format hard drive commands
    PowerShell format hard drive commands

Once you complete the steps, the newly formatted hard drive will appear on “This PC” and ready to use in File Explorer. If you’re having trouble with any of the commands, you can get help at the Pureinfotech forums.