How To Rebuild a Drive with PowerShell
Hunter Ryskoski
3 min read · Just now
Sometimes the fastest way to fix a drive issue is to start fresh.
Whether you are preparing a machine for a clean Windows install, repurposing a device, or clearing out an old partition layout, there are times when you need to completely wipe a disk and rebuild it with the correct partition style.
One of the quickest ways to do that on a Windows machine is through PowerShell using DiskPart.
This week, I used the following commands:
diskpart
select disk 0
clean
convert gpt
exit
exit
It is a very short command sequence, but it does something extremely important.
What These Commands Actually Do
At a glance, this might look simple. In reality, it is a full reset of the selected disk’s partition structure.
Here is what each command does:
diskpart
This launches the DiskPart utility from PowerShell.
DiskPart is a built-in Windows command-line tool used to manage disks, partitions, and volumes.
select disk 0
This tells DiskPart which disk you want to work with.
In this case, it selects Disk 0, which is often the primary internal drive on a machine. That is why it is so important to verify the disk number before running anything destructive.
clean
This removes the partition and volume information from the selected disk.
In plain English, it wipes the current disk layout so the drive becomes unallocated space. This is the point of no return for most practical purposes.
convert gpt
This changes the disk’s partition style to GPT.
GPT stands for GUID Partition Table, and it is the modern partitioning standard used with most current systems.
exit
This exits DiskPart.
exit
This exits the PowerShell session.
Why Convert a Disk to GPT?
GPT is generally the right choice for modern Windows deployments. If you are installing Windows 11, or even just trying to align with current best practices, GPT is usually the format you want.
Why This Can Be Useful
There are a few common situations where this process makes sense:
- preparing a PC for a clean operating system install
- fixing a disk with a corrupted or messy partition layout
Sometimes Windows setup issues are not really “Windows issues” at all. They are disk layout problems. Starting from a clean GPT disk can remove a lot of unnecessary friction.
The Important Warning
This process is destructive.
Running clean erases the partition structure on the selected disk. That means the data and existing layout are removed from normal access. Before doing this, make sure:
- you have selected the correct disk
- anything important is backed up
- you are intentionally wiping the drive
If you are unsure which disk is which, use:
list disk
before selecting a disk.
That one extra step can save you from wiping the wrong drive.
Final Thoughts
I like command-line tools like DiskPart because they are direct. No extra clicks, no guessing, no hidden menus. You tell the system exactly what to do, and it does it.
That said, the same thing that makes DiskPart useful also makes it dangerous: it does exactly what you tell it to do.
Used correctly, this is a quick and effective way to reset a drive and prepare it for a modern Windows deployment. Just make sure Disk 0 is really the disk you want before you press Enter on clean.
Written by Hunter Ryskoski — IT support specialist, Power BI builder, and tech writer sharing practical fixes, lessons learned, and real-world how-to content.
Top comments (0)