How to Fix the ‘Parameter Cannot Be Found’ Error When Running PowerShell from a Batch File?

0
33
Asked By CuriousFalcon99 On

I've been trying to run a PowerShell script from a batch file to remove OneDrive, but I'm running into an error. I have two files in C:Temp: RemoveOneDrive.ps1 and RemoveOneDrive.bat. The PowerShell script works perfectly on its own, but when I try to execute it from the batch file using the command `Powershell.exe Set-ExecutionPolicy RemoteSigned -File "C:TempRemoveOneDrive.ps1"`, I get an error stating that a parameter cannot be found that matches the parameter name 'File'. Can anyone help me figure out what I'm doing wrong? Thanks in advance!

1 Answer

Answered By TechnoNerd42 On

It looks like the issue with your batch file is in how you're structuring the command. Instead of `Powershell.exe Set-ExecutionPolicy RemoteSigned -File "C:TempRemoveOneDrive.ps1"`, try using `Powershell.exe -ExecutionPolicy RemoteSigned -File "C:TempRemoveOneDrive.ps1"`.

CuriousFalcon99 -

Thanks for the quick reply! I made that change, but now I'm seeing a different error. It says that the file isn't digitally signed and cannot be run. What do I do about that?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.