Recently, I was facing an error in PowerShell stating “execution of scripts is disabled on this system” on Windows 11. Currently, I am using Windows 11 with PowerShell 5.1 and Let’s include all possible solutions for this PowerShell error. Firstly, You can resolve this error permanently or just resolve the error for the time being.
Windows PowerShell execution policies let you determine the conditions under which Windows PowerShell loads configuration files and runs scripts.
Execution Policy Type:
The acceptable execution policy values are as follows:
- Default. Firstly, The default execution policy is Restricted for Windows clients and RemoteSigned for Windows Servers.
- Bypass. Secondly, You can set Bypass execution policy. Now, PowerShell is neither blocking anything nor display any warnings or prompts.
- AllSigned. Further, this Requires that all scripts and configuration files are signed by a trusted publisher, including scripts written on the local computer.
- RemoteSigned. Subsequently, you need a trusted publisher in RemoteSigned execution policy.
- Thus, it is a default execution policy for Windows server computers.
- Restricted. In addition, it doesn’t load configuration files or run scripts. Hence, this is the default execution policy for Windows client computers.
- Undefined. Specifically, You can use the execution policy to Undefined but the effective execution policy is Restricted.
- Unrestricted. Loads all configuration files and runs all scripts. Meanwhile, If you run an unsigned script that was downloaded from the internet, you’re prompted for permission before it runs.
- Firstly, This is default execution policy since PowerShell 6.0. Secondly, You cannot change default execution policy for non-Windows computers.
Execution of Scripts is Disabled on this System
Above all, you can fix this error from the list below and any solution can work for you based on the previous configuration. Meanwhile, you can continue reading the solution section.
- Run as Administrator Solution
- Firstly, Locate PowerShell and “Run as Administrator“. I believe, this will work in most of the cases when the user has administrator privileges.
- Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
- Certainly, if you don’t have administrator privileges, you can run Set-ExecutionPolicy RemoteSigned command in your PowerShell ISE console to remove this error.
- Set-ExecutionPolicy -ExecutionPolicy RemoteSigned –Scope Process
- You can also use -Scope to restrict this for Process or CurrentUser etc.
- You can use ExecutionPolicy to “RemoteSigned” or “Bypass” or “Restricted“.
- Set-ExecutionPolicy -ExecutionPolicy Unrestricted
- Afterwards, I am less likely user of Set-ExecutionPolicy -ExecutionPolicy Unrestricted command as it is highly insecure, letting you to run unsigned scripts from any source.
- You can set
unrestricted
as a last resort but it shouldn’t be your starting point.
- Indeed, You can unset a previously set policy in a given scope, use
Undefined
.
Turn on Script Execution System with Group Policy
Finally, you can can enable all scripts in local group policy.
- Firstly, Open Run Command and typ gpedit. msc (Group Policy Editor).
- Secondly, You need to navigate on this location:
- Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
- Enable “Turn on Script Execution” and Set the execution policy as needed.
- Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
Allow PowerShell Scripts in Windows 11 from Settings
Additionally, You can turn on PowerShell settings to execute PowerShell Scripts. This settings has a clear statement that describe as under.
Change execution policy to allow local PowerShell scripts to run without signing. Required signing for remote scripts
Again, you need to locate Settings on your Windows 11 computer. Then, you need to navigate Privacy & Security. Afterwards, you need to click For developers, then locate PowerShell. Once found, turn it on.
PowerShell Scripts
Meanwhile, I am writing many useful PowerShell scripts and you can read all these under PowerShell scripts tag section. Meanwhile, you may share it with others or can show up yourself in comments.
References
- You can read Set-ExecutionPolicy documentation.