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

Whenever you get a new hard drive that you’re planning to connect to a Windows 10 PC, you need to format it to properly delete any data and set up a compatible file system to allow Windows 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, whether it’s a new drive or you simply want to delete everything and start over.

How to properly format a drive using PowerShell commands

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. 

  1. Open Start.

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

  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 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.

  7. 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.

    PowerShell format hard drive commands
    PowerShell format hard drive commands

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