Setting PowerShell Execution Policy Remotely

April 13, 2008 – 8:20 pm

 

So, you have seen the light and want to use PowerShell for all your daily tasks. By default the PowerShell execution policy is set to Restricted, meaning that PowerShell does not load configuration files and does not run scripts. You will have to change the execution policy for any machine you want to run scripts on. For a large number of machines that would be a pain so I will give you three different methods for setting the execution policy for PowerShell.

PowerShell Command

So the first method is actually just running a PowerShell command. You can set the PowerShell execution policy by running

powershell -command "& {set-executionpolicy remotesigned}"

This just runs the set-executionpolicy cmdlet directly so it bypasses the script restriction. This solution is ideal for using via psexec or in a scripted build solution. I use the Altiris Deployment Solution to build my servers so I just add this command as a step in the build job.

Registry

The second solution is to set the execution policy via the ever present registry. You can set the execution policy directly by setting the value to the desired execution policy.

Key: HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell\
Value Name: ExecutionPolicy

Group Policy

The last solution is to set the execution policy with a Windows Group Policy Object. After spending some time creating my own template I discovered that Microsoft actually created a template to use. It has sections in the computer and user area and can be downloaded here.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • e-mail
  • Live
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

You must be logged in to post a comment.