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!


Posted Jul 28 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.