Cleans a disk by removing all partition information and un-initializing it, erasing all data on the disk.

      Clear-Disk [-Number] UInt32[]
        [-RemoveData] [-RemoveOEM] [-CimSession CimSession[]]
           [-ThrottleLimit Int32] [-AsJob]
              [-PassThru] [-WhatIf] [-Confirm] [CommonParameters]

      Clear-Disk -UniqueId String[]
        [-RemoveData] [-RemoveOEM] [-CimSession CimSession[]]
           [-ThrottleLimit Int32] [-AsJob]
              [-PassThru] [-WhatIf] [-Confirm] [CommonParameters]

      Clear-Disk [-FriendlyName String[]]
        [-RemoveData] [-RemoveOEM] [-CimSession CimSession[]]
           [-ThrottleLimit Int32] [-AsJob]
              [-PassThru] [-WhatIf] [-Confirm] [CommonParameters]

      Clear-Disk -Path String[]
        [-RemoveData] [-RemoveOEM] [-CimSession CimSession[]]
           [-ThrottleLimit Int32] [-AsJob]
              [-PassThru] [-WhatIf] [-Confirm] [CommonParameters]

      Clear-Disk -InputObject CimInstance[]
        [-RemoveData] [-RemoveOEM] [-CimSession CimSession[]]
           [-ThrottleLimit Int32] [-AsJob]
              [-PassThru] [-WhatIf] [-Confirm] [CommonParameters]

   -AsJob        Run the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.

   -CimSession   Run the cmdlet in a remote session or on a remote computer.
                 Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet.
                 The default is the current session on the local computer.

   -Confirm      Prompts for confirmation before running the cmdlet.

   -FriendlyName A friendly name of the disk to clear.

   -InputObject  The input object that is used in a pipeline command.
                 You can pipe a Disk object to the -InputObject parameter.

   -Number       The disk number of the disk on which to perform the clear operation.
                 For a list of available disks, see the Get-Disk cmdlet.

   -PassThru     The cmdlet should output an object representing a disk.
                 By default, this cmdlet does not generate any output.

   -Path         Specifies the path of the disk to clear.

   -RemoveData   Enables the removal of all of the data on the disk.

   -RemoveOEM    Enables the removal of any OEM recovery partitions from the disk.

   -ThrottleLimit Specifies the maximum number of concurrent operations that can be established to run the cmdlet.
                  If this parameter is omitted or a value of 0 is entered, then Windows PowerShell calculates
                  an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running
                  on the computer. The throttle limit applies only to the current cmdlet, not to the session.

   -UniqueId     Specifies the UniqueID of the disk to clear.

   -WhatIf       Shows what would happen if the cmdlet runs. The cmdlet is not run.

Standard Aliases for Clear-Disk: none

The Clear-Disk cmdlet clears the disk by removing the partition and volume information. If the disk contains active data volumes, then the -RemoveData parameter is required as this will delete all data from the specified disk. This cmdlet will not clear OEM recovery partitions unless RemoveOEM parameter is also specified.

When used in Failover Cluster, cmdlets from the Storage module operate on cluster level (all servers in the cluster).


Clear a blank disk, only if it does not contain data or an OEM partition:

PS C:\> Clear-Disk -Number 1

Clear a disk if it has data partitions, but not if it also has an OEM partition:

PS C:\> Clear-Disk -Number 1 -RemoveData

Clear a disk regardless of whether it contains data or any OEM partitions:

PS C:\> Clear-Disk -Number 1 -RemoveData -RemoveOEM

“More than once, I've wished my real life had a delete key” ~ Harlan Coben

Related PowerShell Cmdlets

Get-Disk - Get one or more disks visible to the OS.
Set-Disk - Set attributes and update a physical disk.
DISKPART - Disk Administration, Partition a disk.

Copyright © 1999-2024
Some rights reserved