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

September 1, 2025 1 answer
Asked by CuriousFalcon99
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!

Answers

TechnoNerd42
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?

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions