Fix Execution of Scripts Is Disabled on This System
In this article
To fix the “execution of scripts is disabled on this system” error, you need to change the PowerShell execution policy to allow scripts to run, typically by running Set-ExecutionPolicy RemoteSigned as an administrator. This error appears when you try to run a PowerShell script (a .ps1 file) on Windows and the system’s execution policy blocks it for security reasons.
What Causes This Error
PowerShell has a built-in security feature called the execution policy. It controls under what conditions PowerShell loads configuration files and runs scripts. The policy is not a security boundary—it is designed to prevent users from accidentally running malicious scripts. When the policy is set to Restricted (the default on most Windows client systems), no scripts can run at all, and you get the error message: “File C:\path\to\script.ps1 cannot be loaded because running scripts is disabled on this system.”
This error is common when you download a script from the internet or when a developer provides a .ps1 file for a task like installing a tool or configuring a service. The policy also applies in the Windows PowerShell ISE and in the PowerShell console, but not in the PowerShell 7 (pwsh) if it has its own separate policy. The error can also appear in other contexts, such as when a build script in Visual Studio or a CI pipeline invokes PowerShell.
Understanding PowerShell Execution Policies
PowerShell offers several execution policy levels. The most common ones are:
- Restricted – No scripts run. This is the default on Windows client editions.
- AllSigned – Only scripts signed by a trusted publisher can run.
- RemoteSigned – Locally created scripts run without a signature; scripts downloaded from the internet must be signed by a trusted publisher.
- Unrestricted – All scripts run, but you are prompted before running scripts downloaded from the internet.
- Bypass – Nothing is blocked; no prompts or warnings.
The policy is stored in the registry and can be set at different scopes: MachinePolicy, UserPolicy, Process, CurrentUser, and LocalMachine. The effective policy is the most restrictive one that applies. For example, if the LocalMachine policy is Restricted and the CurrentUser policy is RemoteSigned, the effective policy is Restricted because it is more restrictive.
How to Fix the Error
The most straightforward fix is to change the execution policy for the current user. Open PowerShell as an administrator (right-click the Start button and select “Windows PowerShell (Admin)” or “Terminal (Admin)”). Then run:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUserWhen prompted, type Y and press Enter. This allows locally created scripts to run and requires downloaded scripts to be signed. If you need to run a script you downloaded, you can unblock it first with Unblock-File -Path .\script.ps1 instead of changing the policy to Unrestricted.
If you are in a corporate environment and the policy is enforced via Group Policy, you may not be able to change it. In that case, contact your system administrator. Alternatively, you can run a script for a single session without changing the policy permanently:
powershell -ExecutionPolicy Bypass -File .\script.ps1This launches a new PowerShell process with the Bypass policy, which allows the script to run. It is a temporary solution and does not alter the system-wide policy.
Check the Current Execution Policy
Before making changes, it is useful to see what policy is currently in effect. Run:
Get-ExecutionPolicy -ListThis shows the policy for each scope. The EffectivePolicy column tells you which policy is actually applied. If the effective policy is Restricted, that explains the error. You can also check the ExecutionPolicy property of the process with Get-ExecutionPolicy.
If you see Undefined for all scopes, the default policy is used, which is Restricted on Windows client. On Windows Server, the default is RemoteSigned.
Common Problems and Misconceptions
One common mistake is running Set-ExecutionPolicy without administrative rights. Changing the LocalMachine scope requires elevation. If you get an “Access to the registry key” error, you are not running as administrator. Use the CurrentUser scope instead, which does not require elevation.
Another misconception is that changing the execution policy to Bypass is safe. It is not recommended for daily use because it disables all script-blocking protections. A better approach is to use RemoteSigned and unblock individual downloaded files.
Some users try to run a script by double-clicking it. By default, double-clicking a .ps1 file opens it in Notepad, not in PowerShell. You must right-click and choose “Run with PowerShell,” or run it from the console. Even then, the execution policy applies.
If you are using the PowerShell ISE, it uses the same execution policy as the console. However, the ISE may have a separate setting in some older versions, but modern Windows 10/11 does not.
Another issue: if you are using a 64-bit system, there are separate execution policies for 32-bit and 64-bit PowerShell. You may need to set the policy in both versions if you use both.
Safety Considerations
Changing the execution policy can expose your system to risks. Only change it if you trust the scripts you intend to run. Always review the contents of a script before executing it. You can open the .ps1 file in a text editor to see what it does. Look for suspicious commands like Invoke-WebRequest to download and execute code, or Set-MpPreference to disable antivirus.
If you only need to run a script once, use the Bypass flag as shown earlier. It is safer than permanently setting the policy to Unrestricted. Also, consider using RemoteSigned and unblocking files, because that keeps protection against unsigned internet downloads.
If you are in a managed environment, do not try to bypass Group Policy. That could violate security policies and get you in trouble. Instead, ask your administrator to allow the specific script.
Alternatives to Changing the Policy
If you cannot change the execution policy, you have a few alternatives:
- Run the script as a one-liner:
powershell -Command "& 'C:\path\script.ps1'"– this may still be blocked by the policy. - Convert the script to a batch file (.bat or .cmd) that calls PowerShell with the
-ExecutionPolicy Bypassflag. - Use a different scripting language like Python or Node.js if the task is not PowerShell-specific.
- Run the script in a PowerShell 7 (pwsh) session if installed. PowerShell 7 uses its own execution policy, which may be different from Windows PowerShell 5.1.
Another option is to sign the script with a code-signing certificate. If you have a trusted certificate, you can set the policy to AllSigned and run signed scripts. This is more secure but requires purchasing a certificate or setting up an internal PKI.
Frequently Asked Questions
Why do I get this error even when I am an administrator?
Being an administrator does not bypass the execution policy. The policy applies to all users, including administrators. You need to change the policy explicitly. Also, if the policy is set by Group Policy, even administrators cannot override it without changing the GPO.
What is the difference between RemoteSigned and Unrestricted?
RemoteSigned requires scripts downloaded from the internet to be signed by a trusted publisher. Locally created scripts run without a signature. Unrestricted runs all scripts, but it prompts you before running scripts downloaded from the internet. RemoteSigned is more secure because it blocks unsigned internet scripts entirely.
Can I set the execution policy to Bypass permanently?
Technically yes, but it is not recommended. Bypass disables all script-blocking checks, which makes it easier for malicious scripts to run. Use it only temporarily for a specific task. For daily use, RemoteSigned is a better balance.
How do I unblock a downloaded script without changing the policy?
Use the Unblock-File cmdlet. For example: Unblock-File -Path .\downloaded.ps1. This removes the “downloaded from the internet” marker, so the script is treated as a local file. Then you can run it under RemoteSigned policy.
Does this error affect .bat or .cmd files?
No, the execution policy only applies to PowerShell scripts (.ps1, .psm1, etc.). Batch files are not affected. If you get a similar error with a .bat file, it is a different issue, such as Command Prompt restrictions via Group Policy.
What if I see “Access to the registry key” when setting the policy?
That error means you do not have permission to change the LocalMachine scope. Run PowerShell as administrator, or use the -Scope CurrentUser parameter, which does not require admin rights.