Reputation: 2061
I'm trying to run simple Powershell script (eg. just with dir command) on Windows Server 2008 using external program which will call Powershell
powershell.exe "& 'C:\Temp\myscript.ps1'"
I have set (run as administrator) execution-policy unrestricted. After all, I get this error from the client
99: File C:\Temp\myscript.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please
see "get-help about_signing" for more detai ls. At line:1 char:2 + & <<<< 'C:\Temp\myscript.ps1' + CategoryInfo
: NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException
Why I'm getting this error? Isn't unrestricted execution policy enough?
Upvotes: 1
Views: 726
Reputation: 25800
Or
You can use -ExecutionPolicy parameter of PowerShell.exe to set the execution policy to unrestricted only for that session. This helps in keeping the system wide policy to deafult.
Upvotes: 4