Getting and Setting the PowerShell Execution Policy on a Local Computer

With some simple Windows PowerShell commands, you can find out the current PowerShell execution policy that's set on a local computer and change it if necessary.

Jan De Clercq

November 11, 2014

1 Min Read
Windows Gatekeeper QAs
Windows Gatekeeper Q&As

Q: How can I get the current PowerShell execution policy setting on my Windows machine? How can I modify this setting? Is there an easy way I can temporarily bypass the execution policy in a current PowerShell session?

A: To get the current PowerShell execution policy, you can simply type Get-ExecutionPolicy at the PS prompt, as Figure 1 shows.

 logo in a gray background |

To look at all the execution policies and scopes, you can use the Get-ExecutionPolicy cmdlet with the -list parameter. This command's results are also shown in Figure 1. If you're unfamiliar with the various execution policies and scopes, see "Use Execution Policies to Control What PowerShell Scripts Can Be Run."

To change the execution policy, you can use the Set-ExecutionPolicy cmdlet. For example, to change it to Unrestricted, you'd run command:

Set-ExecutionPolicy Unrestricted

To get the execution policy that's set for a particular scope, you must use Get-ExecutionPolicy cmdlet with the -scope parameter.

When running an administrative script, administrators sometimes bypass the execution policy by changing the execution policy to Unrestricted before running the script, then changing the policy back to Restricted after the script runs. The risk here is that an administrator might forget to return the system to the "higher protection" state when done. A safer way to relax the execution policy for your current PowerShell session is to use the Bypass parameter, as follows:

Set-ExecutionPolicy Bypass

Note that to change the execution policy for the local computer in Windows Vista and later versions, you must start PowerShell with administrator privileges (i.e., use the Run as administrator option).

 

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like