How to Enable Execution of PowerShell Scripts

powershell

When I try to execute my PowerShell script I get this error:

File C:\Common\Scripts\hello.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:13
+ .\hello.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException

Best Answer

  1. Start Windows PowerShell with the "Run as Administrator" option. Only members of the Administrators group on the computer can change the execution policy.

  2. Enable running unsigned scripts by entering:

    set-executionpolicy remotesigned
    

This will allow running unsigned scripts that you write on your local computer and signed scripts from Internet.

See also Running Scripts at Microsoft TechNet Library.

Related Question