Repair-Volume
Performs repairs on a volume.
Syntax
ByDriveLetter (Default)
Repair-Volume
[-DriveLetter] <Char[]>
[-OfflineScanAndFix]
[-SpotFix]
[-Scan]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ById
Repair-Volume
-ObjectId <String[]>
[-OfflineScanAndFix]
[-SpotFix]
[-Scan]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByPaths
Repair-Volume
-Path <String[]>
[-OfflineScanAndFix]
[-SpotFix]
[-Scan]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByLabel
Repair-Volume
-FileSystemLabel <String[]>
[-OfflineScanAndFix]
[-SpotFix]
[-Scan]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
InputObject (cdxml)
Repair-Volume
-InputObject <CimInstance[]>
[-OfflineScanAndFix]
[-SpotFix]
[-Scan]
[-CimSession <CimSession[]>]
[-ThrottleLimit <Int32>]
[-AsJob]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Repair-Volume cmdlet performs repairs on a volume. The following repair actions are available:
OfflineScanAndFix: Takes the volume offline to scan the volume and fix any errors found (equivalent to chkdsk /f
).
Scan: Scans the volume without attempting to repair it; all detected corruptions are added to the $corrupt
system file (equivalent to chkdsk /scan
).
SpotFix: Takes the volume briefly offline and then fixes only issues that are logged in the $corrupt
file (equivalent to chkdsk /spotfix
).
Examples
EXAMPLE 1
PS C:\>Repair-Volume -DriveLetter H -Scan
This example scans the volume H: and reports errors only. It uses the -DriveLetter
switch to designate the volume by its drive letter and -Scan
to indicate the scanning action.
EXAMPLE 2
PS C:\>Repair-Volume -DriveLetter GHI -SpotFix
This example uses the spot verifier functionality to quickly fix volumes designation G:, H: and I:. It uses the -DriveLetter
switch to designate multiple volumes by their drive letters and SpotFix
to indicate the quick fixing action.
EXAMPLE 3
PS C:\> Get-Volume
DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size
----------- ------------ -------------- --------- ------------ ----------------- ------------- ----
System Reserved NTFS Fixed Healthy OK 178.47 MB 550 MB
C Contoso - C NTFS Fixed Healthy OK 41.28 GB 98.89 GB
NTFS Fixed Healthy OK 89.03 MB 481 MB
FAT32 Fixed Healthy OK 70.8 MB 96 MB
D Contoso - D NTFS Fixed Healthy OK 29.13 GB 67.68 GB
E Contoso - E NTFS Fixed Healthy OK 148.44 GB 465.76 GB
F Archives NTFS Fixed Healthy OK 324.13 GB 465.76 GB
PS C:\> Repair-Volume -FileSystemLabel "System Reserved" -OfflineScanAndFix
This example takes the System Reserved volume offline, and fixes all issues. This volume has no drive letters assigned to it. The first command, Get-Volume
gives an overview of the volumes on the local computer. As the output indicates, the volume bearing the "System Reserved" label has no drive letters. Next, the Repair-Volume
cmdlet uses the -FileSystemLabel
switch to designate the "System Reserved" volume and the -OfflineScanAndFix
switch indicates the volume should be taken offline and scanned in full.
Parameters
-AsJob
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-CimSession
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
Parameter properties
Type: | CimSession[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Session |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | cf |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-DriveLetter
Specifies a letter used to identify a drive or volume in the system.
Parameter properties
Type: | Char[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByDriveLetter
Position: | 0 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-FileSystemLabel
Specifies the volume to scan based on the file system label (the volume name).
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByLabel
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-InputObject
Specifies the input to this cmdlet. You can use this parameter, or you can pipe the input to this cmdlet.
Parameter properties
Type: | CimInstance[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
InputObject (cdxml)
Position: | Named |
Mandatory: | True |
Value from pipeline: | True |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ObjectId
Specifies an ID representing the object. The ID is not globally unique.
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Aliases: | Id |
Parameter sets
ById
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-OfflineScanAndFix
Performs and offline scan and fix of any errors found in the file system.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Path
Contains valid path information.
Parameter properties
Type: | String[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ByPaths
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | True |
Value from remaining arguments: | False |
-Scan
Scans the volume.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-SpotFix
Takes the volume offline and fixes any issues that are logged in the $corrupt file.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ThrottleLimit
Specifies the maximum number of concurrent operations that can be established to run the cmdlet.
If this parameter is omitted or a value of 0
is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer.
The throttle limit applies only to the current cmdlet, not to the session or to the computer.
Parameter properties
Type: | Int32 |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
Type: | SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | wi |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
CimInstance
The Microsoft.Management.Infrastructure.CimInstance
object is a wrapper class that displays Windows Management Instrumentation (WMI) objects.
The path after the pound sign (#
) provides the namespace and class name for the underlying WMI object.
Outputs
UInt32
Notes
- When used in Failover Cluster, cmdlets from the Storage module operate on cluster level (all servers in the cluster).