0

I have created a PowerShell script to get files from a subfolder. This executes when I run from the PowerShell console after manually entering Set-ExecutionPolicy unrestricted, but when I call the same script from a batch file

C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe D:\programs\abc\bin\xyz_clean.ps1

it throws an error:

xyz_clean.ps1 cannot be loaded because the execution of scripts is disabled on this system.

9

1 Answer 1

2

You can just call powershell from a command window:

C:\> powershell /?
C:\> powershell -executionpolicy unrestricted -file \\server\file.ps1

then save it to a .bat file:

C:\> echo powershell -executionpolicy unrestricted -file \\server\file.ps1 > file.bat
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.