1
votes

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?

1
Problem solved: There is two Powershell's in Windows Server 2008, x64 and x86. I had to set execution policy unrestricted in both of them. - jjoras

1 Answers

4
votes

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.