How to enable execution of PowerShell scripts?

  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.


The Default Execution Policy is set to restricted, you can see it by running Get-ExecutionPolicy:

Get-ExecutionPolicy

Run Set-ExecutionPolicy like this to switch to the unrestricted mode:

Set-ExecutionPolicy unrestricted

On my machine that I use to dev scripts, I will use -unrestricted as above. When deploying my scripts however, to an end user machine, I will just call powershell with the -executionpolicy switch:

powershell.exe -noprofile -executionpolicy bypass -file .\script.ps1

Tags:

Powershell