page contents

About the Post

Author Information

HOW TO: Set The PowerShell Execution Policy

If you are having been using the new ability to manage servers remotely using command line tools, then I am sure you have been using PowerShell. If you are new to command line tools, then this may seem strange to you, but trust me, Microsoft has been doing a great job making it easier to use and more powerful with each release. If you ever get stuck, then please try out the cmdlet (pronounced command let) Get-Help and in most cases it will clear things up for you.

One of the first things you may have run into is trying to execute an existing PowerShell script on a newly installed Windows server and getting an error, like this one:

scriptname.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.

Here is the list of available PowerShell execution policies (please note the Default) with a brief description of each:

AllSigned: All scripts as well as configuration files must be signed by a trusted publisher. This includes script on the local as well as remote machines.

Default: Uses the default Restricted policy.

RemoteSigned: All scripts as well as configuration files downloaded via the Internet must be signed by a trusted publisher.

Restricted: As mentioned this is the PowerShell default and will not allow you to execute scripts or load configuration files.

Unrestricted: This allows you to execute all scripts as well as load configuration files however if you download a script from the internet you are prompted to approve it before it can execute.

To change the PowerShell Execution Policy which you can execute any of the following above from within the PowerShell command window:

In my case, I tend to go with the Set-ExecutionPolicy RemoteSigned

You can also change the Execution Policy via the registry by navigating to the following:

HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

Then locate the string value ExecutionPolicy and add any value from the list below:

Restricted
AllSigned
RemoteSigned
Unrestricted

For example if you want to set your PowerShell execution policy for RemoteSigned add the following:

HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
“ExecutionPolicy”=”RemoteSigned”

Tags: , , , ,

Comments are closed.

Copy Protected by Chetan's WP-Copyprotect.