Skip to content

How to enable the execution of PowerShell scripts?

Last updated on January 25, 2021

The PowerShell execution policy is set to Restricted by default. You can change the PowerShell execution policies with the Set-ExecutionPolicy cmdlet. Only members of the Administrators group on the computer can change the execution policy.

Start Windows PowerShell with the “Run as Administrator” option. and run the below command with the desired execution policy option.

PS D:\pstest> Set-ExecutionPolicy RemoteSigned 

Below is the list of four different execution policies in PowerShell

  • Restricted – No scripts can be run.
  • AllSigned – Only scripts signed by a trusted publisher can be run.
  • RemoteSigned – Downloaded scripts must be signed by a trusted publisher.
  • Unrestricted – All Windows PowerShell scripts can be run

We can see the current session execution policy by running Get-ExecutionPolicy:

PS D:\pstest> Get-ExecutionPolicyRestricted

You can bypass the policy by adding -ExecutionPolicy ByPass parameter when running the PowerShell script as shown below.

PS D:\pstest> powershell -ExecutionPolicy ByPass -File test.ps1

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments