How To Enable Powershell Execution Policy on any windows computer for Powershell scripts to work as expected, here are the steps to how to do it.
When you run a PowerShell script and if it says “execution of scripts is disabled on this system”, what does it mean? It means the execution policy is set as restricted, let’s learn what are execution policies and how to set them for use.
No Script either local, remote or downloaded can be executed on the system.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
All scripts that run require to be digitally signed.
Set-ExecutionPolicy -ExecutionPolicy Allsigned
All remote scripts (UNC) or downloaded need to be signed.
Set-ExecutionPolicy -ExecutionPolicy Remotesigned
No signature for any type of script is required.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Scope of new Change
The execution policy affects all users of the computer.
The execution policy affects only the current user.
The execution policy affects only the current Windows PowerShell process, to check your current execution policy, you can run Get-ExecutionPolicy and get the current policy.
- Go to Start Menu and search for “Windows PowerShell ISE”.
- Right click the x86 version and choose “Run as administrator”
- Open PowerShell as Administrator and run Set-ExecutionPolicy -Scope CurrentUser
- Provide RemoteSigned and press Enter
- Run Set-ExecutionPolicy -Scope CurrentUser
- Provide Unrestricted and press Enter
By default it is Restricted. To change the execution of PowerShell scripts we need to set this ExecutionPolicy either as Bypass or Unrestricted.
We can set the policy for Current User as
Unrestricted by using any of the below PowerShell commands:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force; Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force;
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply