Invoke-RepairVolume
Description
This script allows a technician to run the PowerShell equivalent of chkdsk on any or all drives, with the option to repair any found issues.
Usage
- If no drive letters are provided, get all drive letters.
- Determine the scope:
- No Repair option - Runs
Repair-Volume
on that drive with the-Scan
switch.
To prevent disrupting a volume’s availability, you can scan a volume without attempting to repair it. All detected corruptions are added to the$corrupt
system file. This is equivalent to runningchkdsk /scan
. - Repair - non-full - Runs
Repair-Volume
on that drive with the-SpotFix
switch.
This option will temporarily take the volume offline for the time needed to fix those identified errors. This is equivalent to runningchkdsk /spotfix
. - Repair - Full - Runs
Repair-Volume
on that drive with the-OfflineScanAndFix
switch.
This option will take the volume offline in order to perform a full scan and fix any errors found along the way. This requires the most time but is also the most comprehensive. This is equivalent to runningchkdsk /f
.
- No Repair option - Runs
- Return the results of running the command.
.\Invoke-RepairVolume.ps1
Returns the state of all internal drives' health and adds any corruptions to the $Corrupt
system file.
.\Invoke-RepairVolume.ps1 -DriveLetter C
Returns the state of the C drive's health.
.\Invoke-RepairVolume.ps1 -DriveLetter C -Repair
Will attempt to repair any found issues on the C drive, stopping the C drive only when necessary.
.\Invoke-RepairVolume.ps1 -Repair -Full
Will attempt to repair any found issues on all drives; this will render the hard drive offline during the process.
Parameters
Parameter | Alias | Required | Default | Type | Description |
---|---|---|---|---|---|
DriveLetters | False | String[] | A string array to hold target drives. | ||
Repair | False | Switch | Toggles the repair option. | ||
Full | False | Switch | Toggles the full offline repair option when using repair. |
Output
Logs
.\Invoke-RepairVolume-log.txt
Console
System-Object
Formatted as: | DriveLetter | ScanResults |