PowerShell for Windows Admins

Jul 13 2014   9:34AM GMT

Formatting disks

Richard Siddaway Richard Siddaway Profile: Richard Siddaway


Saw a question on the forums about formatting all disks but the C: drive. Assuming you ever need to do such a destructive activity you might want think about this sort of approach:

Get-CimInstance -ClassName Win32_Volume -Filter “DeviceId != ‘C:'” |
foreach {
Invoke-CimMethod -whatif -InputObject $psitem -MethodName Format -Arguments @{
ClusterSize = 4096
EnableCompression = $false
FileSystem = ‘NTFS’
QuickFormat = $true

Notice I’ve left the –whatif in for safety

More details on the Win32_Volume class at http://msdn.microsoft.com/en-us/library/aa394515%28v=vs.85%29.aspx

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: