Powershell

Windows PowerShell Policy Execution Bypass

PowerShell execution policy is a security feature that decides whether to run a specific script in the console or not. There are six execution policies in PowerShell, including “AllSigned”, “Bypass”, “RemoteSigned”, “Restricted”, “Undefined”, or “Unrestricted”. More specifically, the PowerShell’s default execution policy is set to “Restricted”, which does not let PowerShell run the scripts. However, enabling the “Bypass” execution policy in PowerShell, lets the users execute scripts from anywhere because it bypasses all the restrictions.

In this post, PowerShell’s “Bypass” execution policy will be elaborated.

Windows PowerShell Policy Execution Bypass

As stated above, when the “Bypass” execution policy is enabled, it eliminates all the restrictions that were stopping the script from executing in PowerShell.

Examples of enabling the “Bypass” execution policy in PowerShell are given below.

Example 1: Set the Execution Policy to “Bypass” for the PowerShell Console

This demonstration will enable the “Bypass” execution policy in PowerShell:

Set-ExecutionPolicy -ExecutionPolicy Bypass

Let’s verify, whether the execution policy was enabled or not by executing the below command:

Get-ExecutionPolicy

Example 2: Set the Execution Policy to “Bypass” for the PowerShell ISE

This example will enable the “Bypass” execution policy in the PowerShell scripting:

Set-ExecutionPolicy -ExecutionPolicy Bypass

Get-ExecutionPolicy

Example 3: Set the Execution Policy to “Bypass” for a PowerShell Script

In this example, the “Bypass” execution policy will be enabled for a specific script file:

powershell.exe -ExecutionPolicy Bypass C:\New\Array.ps1

According to the above code:

  • First, write out the “powershell.exe” cmdlet followed by the “Get-ExecutionPolicy” cmdlet.
  • After that, add the “-ExecutionPolicy” parameter and then assign it the “Bypass” value.
  • Lastly, specify the path of the script to enable the “Bypass” execution policy:

That was all about setting the “Bypass” execution policy in PowerShell.

Conclusion

Windows PowerShell policy execution bypass is the process to enable the “Bypass” execution policy for the specific script or console. The “Bypass” execution policy is used to lift all the restrictions to execute scripts from anywhere. This post has elaborated on PowerShell’s execution “Bypass” policy with several examples.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.