Idera nSoftware Compellent

PowerShell.com

PowerTip of the Day

Calling ChkDsk via WMI

Some WMI classes contain methods that you can call to invoke some action. For example, the next line initiates a disk check on drive D:

([wmi]"Win32_LogicalDisk='D:'").Chkdsk($true, $false, $false, $false, $false, $true).ReturnValue

Make sure you have administrator privileges or else you receive a return value of 2 which corresponds to "Access Denied".

If you'd like to know what the arguments are for, ask for a method signature:

([wmi]"Win32_LogicalDisk='D:'").Chkdsk

Twitter This Tip! ReTweet this Tip!

Copyright 2010 PowerShell.com. All rights reserved.