Windows Gatekeeper QAs

Windows Gatekeeper Q&As

Getting and Setting the PowerShell Execution Policy on a Local Computer

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.

Figure 1: Getting the Current PowerShell Execution Policy
Figure 1: Getting the Current PowerShell Execution Policy

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).


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.