1

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
  • 2
    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. Commented Nov 10, 2010 at 19:54

1 Answer 1

4

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.

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.