Chkdsk method of the Win32_Volume class

The Chkdsk method invokes the Chkdsk operation on the volume. The method is only applicable to volume instances that represent a physical disk on the computer. It is not applicable to mapped logical drives.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.


uint32 Chkdsk(
  [in] boolean FixErrors = FALSE,
  [in] boolean VigorousIndexCheck = TRUE,
  [in] boolean SkipFolderCycle = TRUE,
  [in] boolean ForceDismount = FALSE,
  [in] boolean RecoverBadSectors = FALSE,
  [in] boolean OkToRunAtBootUp = FALSE


FixErrors [in]

If true, errors found on the disk are fixed. The default is false.

VigorousIndexCheck [in]

If true, a vigorous check of index entries is performed. The default is true.

SkipFolderCycle [in]

If true, the folder cycle checking should be skipped. The default is true.

ForceDismount [in]

If true, the volume is dismounted before checking. The default is false.

RecoverBadSectors [in]

If true, the bad sectors are located and the readable information is recovered. The default is false.

OkToRunAtBootUp [in]

If true, the Chkdsk operation is performed at the next boot up, in case the Chkdsk operation could not be performed because the volume was locked at the time the method was called. The default is false.

Return value

Return code Description
Success - Chkdsk Completed
Success - Volume Locked and Chkdsk Scheduled on Reboot
Unsupported File System
Unknown File System
No Media In Drive
Unknown Error


The following code sample runs a Chkdsk on the specified drive.

# Helper function to Decode Return Code

function Get-DfragReturn {
param ([uint16] $char)

# parse and return values

If ($char -ge 0 -and $char -le 5) {

  switch ($char) {
  0  {"00-Success"}
  1     {"01-sUCCESS (volume locked and chkdsk scheduled for reboot"}
  2  {"02-unsupported file system"}
  3  {"03-Unknown file system"}
  4  {"04-No Media in drive"}
  5  {"05-Unknown Error"}

Else {
 "{0} - *Invalid Result Code*" -f $char}

# Get all local disks
# then get first drive (C:)
$disks=gwmi win32_Volume
$c=$disks | where {$ -eq "C:\"}

# print start
"Checking {0} on system: {1}" -f $,$c.SystemName

# Now specify chkdsk paramaters and call chkdsk

$FixErrors          = $false    # does not fix errors 
$VigorousIndexCheck = $true     # performs a vigorous check of the indexes
$SkipFolderCycle    = $false    # does not skip folder cycle checking.
$ForceDismount      = $false    # will not force a dismount (to enable errors to be fixed)
$RecoverBadSecors   = $false    # does not recover bad sectors
$OKToRunAtBootup    = $false    # runs now, vs at next bootup

"Commencing Defrag"

# Now Display returndvalue 
"Chkdsk call returned: {0}" -f (Get-DfragReturn($res.ReturnValue))

# Finally print time elapsed
"Starting Check Disk at: {0}" -f $start
"Finished at             {0}" -f $finish

$duration = $finish-$start
"Elapsed time            {0} minutes" -f ($duration.totalminutes.tostring("0.00"))

When run, the previous code sample returns the following information:

Checking C:\ on system: LHS1
Commencing Defrag
Chkdsk call returned: 00-Success
Starting Check Disk at: 16/06/2007 16:45:55
Finished at             16/06/2007 16:50:31
Elapsed time            4.59 minutes


Minimum supported client
None supported
Minimum supported server
Windows Server 2003

See also