Question Windows Powershell - Need to run "Repair-Volume" to scan and (possibly) fix logically corrupted flash drive ?

LunkerHead

Distinguished
Jun 13, 2011
39
0
18,540
1
Windows 7 service pack 1

Long story short, I need to use Windows Powershell for a possible fix for a corrupted flash drive. I need to run the "Repair-Volume" command in powershell because I'm getting a checkdisk error "cannot open volume for direct access" when using checkdisk to scan and repair the flash drive. So.. checkdisk is no help. I've have also tried to run the checkdisk scan and repair command from the command prompt started as administrator. No bueno. I discovered I could use powershell to possibly scan and repair the flash drive but when using the Repair-Volume command I get a message saying "repair-volume command not recognized". Well, that led me to find out if the repair-volume module is even installed so then I ran a command to list my installed modules and then I get a message saying that scripts are restricted. So now I need to set my restrictions in powershell to run anything at all.

Does anyone know powershell scripting? I am a noob so I would need some exact commands that I can copy and paste into powershell.

This is what I need to accomplish:
  1. Set powershell executions to unrestricted.
  2. Find out if I even have the repair-volume module installed on my PC and in the right location.
  3. Download and install the repair-volume module if necessary and correctly install it in the right location.
  4. Execute the repair-volume command in Powershell in an attempt to scan and fix the corrupted files on the flash drive.
As you can see in the image I have powershell at the point to set my execution policy to unrestricted but I'm not sure of the exact commands to use:

 
Last edited:

LunkerHead

Distinguished
Jun 13, 2011
39
0
18,540
1
DISM checks the windows Image, I don't think you can use it to scan a USB.

this shows its syntax - https://docs.microsoft.com/en-us/powershell/module/storage/repair-volume?view=windowsserver2022-ps


it could be the USB drive is almost dead. Have you tried another PC?
Thanks for the reply. For some reason I did't get an email saying someone had replied to my post. But, stupidly enough, I was able to change restrictions to unrestricted by simply typing in "unrestricted" for the last command line in the image I posted. After I had full control and tried to run repair volume PowerShell still didn't recognize the repair-volume command. So I figured it was not installed and on top of that I came upon information that PowerShell is nothing more than the "checkdisk/repair errors" command in check disk, and repair-volume is just a wrapper for the normal check disk utility. So knowing that, there wasn't going to be anything that PowerShell could do that the the normal check disk utility couldn't do and so I gave up on PowerShell.

But to answer you question, yeah, I ran some data recovery software on the drive and it turns out the drive has 10's of thousands of bad sectors. What caused the whole issue is that I have a dual boot system with Win7 and Linux Mint. Well, it seems that when I exited Linux with a flash drive still in a USB port without "dismounting" the drive in Linux, when I booted back into Window the drive turned up "dirty" according to an error message I got when trying to run -check disk/fix errors-.

Through some searching for different solutions and trying all kinds of weird stuff I was able to actually bring up the files that were not hosed and copy them back to my HD. A lot of software that I tried wasn't even able to reformat the drive and make it usable again. I can't do anything with it. I can't even delete the readable files that survived. I"m gonna have to smash into a million pieces with a hammer and throw into the trash.
 
Last edited:

ASK THE COMMUNITY

TRENDING THREADS