Calling ChkDsk via WMI

by Jul 28, 2010

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:


Twitter This Tip! ReTweet this Tip!