**Disclosure: This post contains affiliate links. If you make a purchase through these links, we may earn a small commission at no extra cost to you.
Managing your computer’s hardware is usually one of those tasks that you do once and then never have to worry about afterwards. If you are the type who likes to install Windows yourself or even build your own computer, you will defiantly need to do some hardware configuration after you are finished.
You may also run into a situation where the Windows Disk Management tool or DiskPart won’t let you wipe a drive so you can configure it. If you are running into one of these issues or happen to like PowerShell, we will be showing you how to completely wipe and reconfigure a hard drive using PowerShell.
Wiping a Hard Drive using PowerShell
The image below shows the drive that we want to wipe and reconfigure (Disk 1) in the Windows Disk Management tool.
We will now open PowerShell as an administrator to start the process. Then we will run the Get-Disk command to view the hard drives configured on our computer. The drive we want to wipe and reconfigure will be disk number 1, which matches what we see in Disk Management.
To wipe the drive and all its partitions, we will use the following command.
Clear-Disk -Number [DiskNumber] -RemoveData -RemoveOEM -Confirm:$false
We will need to change the DiskNumber section to a 1 and remove the brackets so it looks like the following.
Clear-Disk -Number 1 -RemoveData -RemoveOEM -Confirm:$false
Now when we go back to Disk Management, we can see that there is no volume on the drive and it’s not initialized.
Reconfiguring a Hard Drive using PowerShell
Now that our drive has been wiped, it’s time to reconfigure it so we can use it to store data. We will be using several commands to accomplish this procedure.
The first step involves initializing the disk so we can create a partition or volume on it. You will need to change the disk number for this command to match yours if it’s not disk 1. You can also choose between GPT and MBR.
Initialize-Disk -Number 1 -PartitionStyle GPT
Here is how the disk looks after running the command.
Now we will create a new partition on the drive and use all the space for it. Once again, you will need to change the disk number if needed and also the drive letter if you do not want to use E.
New-Partition -DiskNumber 1 -DriveLetter E -UseMaximumSize
Now we will format the new volume using the NTFS file system.
Format-Volume -DriveLetter E -FileSystem NTFS
If you want to give your new volume a label (name), you can do it from Disk Management, the drives properties by right clicking on it or from PowerShell. We will name our volume Data.
Set-Volume -DriveLetter E -NewFileSystemLabel “Data”
Now we have our hard disk configured and ready to be used to store new data.
For additional training resources, check out our online IT training courses.
Check out our extensive IT book series.