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.
November 11, 2014
![Windows Gatekeeper QAs Windows Gatekeeper QAs](https://eu-images.contentstack.com/v3/assets/blt07f68461ccd75245/bltf34b72d23c45bb6a/66194f5ae72eec3c5c8d85cf/qawebartred_0_0_1.jpg?width=1280&auto=webp&quality=95&format=jpg&disable=upscale)
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
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).
About the Author
You May Also Like