Calling chkdsk from Powershell

%3CLINGO-SUB%20id%3D%22lingo-sub-482936%22%20slang%3D%22en-US%22%3ECalling%20chkdsk%20from%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-482936%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20building%20a%20script%20that%20guides%20an%20end%20user%20through%20the%20process%20of%20running%20a%20basic%20chkdsk%20%2Ff%20on%20USB%20drives%20before%20sending%20them%20back%20out%20to%20the%20field%20for%20our%20techs%20to%20use.%20I%20built%20the%20script%20on%20my%20computer%2C%20I%20also%20do%20not%20run%20with%20Admin%20rights%20on%20the%20machine%2C%20and%20it%20works%20like%20a%20charm.%20However%20I%20moved%20it%20over%20to%20the%20machine%20they%20are%20going%20to%20use%20for%20checking%20and%20now%20I'm%20getting%20some%20weird%20results.%20USB%20drive%20is%20found%20but%20when%20I%20select%20the%20disk%20and%20pass%20that%20to%20the%20chkdsk%20command%20I'm%20told%20that%20it's%20locked%20and%20will%20need%20to%20run%20elevated.%20However%2C%20I%20can%20open%20powershell%20or%20command%20prompt%20directly%20and%20run%20chkdsk%20E%3A%20%2Ff%20and%20it%20works%20no%20problem.%20Am%20I%20missing%20something%20here%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'll%20admit%20I'm%20not%20an%20extremely%20efficient%20Powershell%20guy%2C%20but%20I%20can%20usually%20get%20the%20job%20done%20but%20this%20one%20I%20just%20do%20not%20understand.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-482936%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-646293%22%20slang%3D%22en-US%22%3ERe%3A%20Calling%20chkdsk%20from%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-646293%22%20slang%3D%22en-US%22%3E%3CP%3EIt's%26nbsp%3Bdifficult%20to%20guess%20what%20might%20be%20the%20problem%20here%2C%20possibly%20the%20execution%20policy%20on%20the%20remote%20computer%3F%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20need%20to%20see%20either%20the%20error%20or%20the%20script%20or%20both%2C%20to%20see%20what%20the%20cause%20it.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F326558%22%20target%3D%22_blank%22%3E%40bgawith%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Regular Visitor

I'm building a script that guides an end user through the process of running a basic chkdsk /f on USB drives before sending them back out to the field for our techs to use. I built the script on my computer, I also do not run with Admin rights on the machine, and it works like a charm. However I moved it over to the machine they are going to use for checking and now I'm getting some weird results. USB drive is found but when I select the disk and pass that to the chkdsk command I'm told that it's locked and will need to run elevated. However, I can open powershell or command prompt directly and run chkdsk E: /f and it works no problem. Am I missing something here?

 

I'll admit I'm not an extremely efficient Powershell guy, but I can usually get the job done but this one I just do not understand.

1 Reply
Highlighted

It's difficult to guess what might be the problem here, possibly the execution policy on the remote computer? 

I would need to see either the error or the script or both, to see what the cause it.

@bgawith