
Cybersecurity / Defense and Hardening
Clean (Diskpart Command)
clean (Diskpart Command)
clean is a Diskpart command that removes all partitions or volume formatting from the disk with focus. The disk with focus is the disk currently selected in the Diskpart session; the command operates on that disk. A PowerShell version of the command is available as the clear-disk command.
The command applies to Windows Server 2025, Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows 11, Windows 10, and Azure Local 2311.2 and later.
Syntax
clean [all]
The square brackets mark all as an optional parameter; the command can therefore be run either as clean alone or with the parameter appended.
| Aspect | Detail |
|---|---|
| Function | Removes all partitions or volume formatting from the disk with focus. |
| Optional Parameter | [all] – specifies that each sector on the disk is set to zero, deleting all data. |
| Applies To | Windows Server 2025, 2022, 2019, 2016; Windows 11, 10; Azure Local 2311.2 and later. |
| Equivalent PowerShell Cmdlet | clear-disk |
| Requirement | A disk must be selected via select disk before running clean. |
| Effect on Disk Types | Overwrites MBR/hidden sectors on MBR disks; overwrites GPT partitioning info and Protective MBR on GPT disks (no hidden sectors). |
| Case | Effect |
|---|---|
| MBR disk | only the MBR partitioning information and hidden sector information is overwritten |
| GPT disk | the gpt partitioning information, |
clean command effects by disk type and parameter
Parameter
| Parameter | Description |
|---|---|
all |
Specifies that each and every sector on the disk is set to zero, which completely deletes all data contained on the disk. |
Run without all, the command overwrites the partitioning information described below. With all, the operation extends to every sector on the disk, so that all data the disk contains is completely deleted.
Effect on MBR and GPT Disks
What the command overwrites depends on the partition style of the disk with focus:
- On master boot record (MBR) disks, only the MBR partitioning information and hidden sector information is overwritten.
- On GUID Partition Table (GPT) disks, the GPT partitioning information, including the Protective MBR, is overwritten. GPT disks have no hidden sector information.
The two styles therefore differ in two respects: a GPT disk's Protective MBR is overwritten along with its partitioning information, and hidden sector information exists only on MBR disks.
Disk Selection
A disk must be selected for the operation to succeed. The select disk command selects a disk and shifts the focus to it; clean then removes formatting from that disk. Without a selected disk, the operation cannot succeed.
Example
clean
Related Commands
The PowerShell counterpart clear-disk performs the equivalent operation. Related reference material includes the Command-Line Syntax Key.
Adapted for this library from the original article at https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/clean — see the publisher's site for the authoritative version. (retrieved October 2026).







