[REQUEST] How to Make a Repair-Volume PowerShell Script?

Appletax

Well-Known Member
Reaction score
395
Location
Northern Michigan
I want to use Repair-Volume (PowerShell, new) instead of Check Disk (Command Prompt, old).

Can't get my script to work.

Repair-Volume -DriveLetter C -OfflineScanAndFix

Created in PowerShell ISE and saved as a .ps1 file.

Super basic version. Does not work. Discovered that by default, Windows 10 has PowerShell in Restricted mode - absolutely no PowerShell scripts will run.

Changed to Unrestricted mode to run any PowerShell scripts.

Opened PowerShell with admin privs and ran the script. Tried -ExecutionPolicy ByPass. Nothing works.

If I run the command within PowerShell admin mode (no script used), I instantly get the message "NoErrorsFound".

Here's the PowerShell ISE Debug results:

PowerShell Debug Results.jpg
 
Last edited:
I think I will need to try a different forum for something like this. Perhaps one centered around scripting/programming.

The fact that this is not a piece-of-cake to figure out like Check Disk/Command Prompt is very discouraging. Makes me want to say "eff" it and just continue using my command prompt scripts.
 
I did some searching and it seems that Offline flag doesn't do the prompt for a reboot like chkdsk does if the volume can't be taken offline.


When I run Repair-Volume -DriveLetter C -OfflineScanAndFix, it had a little progress bar but quickly went to No Errors Found. I'm assuming this went so quick since all my volumes are Healthy according to Get-Volume

1642127315065.png

So I plugged in my flash drive, which is dirty. It actually took maybe 30 seconds, and now both volumes on it are healthy.

If you a looking for a full offline scan like on reboot, I think you have to stick with chkdsk.
 
Back
Top