On Windows 11 (or 10), by default, when you try to run a script on PowerShell, it will fail with the “cannot be loaded because running scripts is disabled on this system” error message. This is because PowerShell comes with an “execution policy” security feature that controls how to load configuration files and run scripts to prevent malicious code from running on the system.
If you must run a script on Windows 11 (or 10), you can change the execution policy for the local computer, current user, or session.
When you set a PowerShell execution policy for the local computer and current user, the information will be stored in the Registry. If you set the policy for a particular session, the policy will be held in memory and then lost when you close the session.
According to Microsoft, the execution policy doesn’t restrict the action. You can always bypass the policy by typing the script in the command-line interface (CLI). The execution policy has been designed to help users to prevent running malicious scripts.
This guide will teach you how to change the execution policy to run scripts successfully on PowerShell on Windows 11 or 10.
Change execution policy on PowerShell
To change the execution policy on PowerShell on Windows 11 (or 10), use these steps:
- Open Start on Windows 11.
- Search for PowerShell, right-click the top result, and select the Run as administrator option.
- Type the following command to confirm the current execution policy and press Enter:
- Get-ExecutionPolicy
- (Optional) Type the following command to view the effective PowerShell execution policies and press Enter:
- Get-ExecutionPolicy -List
- Type the following command to change the PowerShell execution policy to allow scripts to run on Windows 11 and press Enter:
- Set-ExecutionPolicy RemoteSigned
- (Optional) Type the following command to change the execution policy to prevent scripts from running and press Enter:
- Set-ExecutionPolicy Restricted
Once you complete the steps, you can execute the script one more time, and it should now run successfully on Windows 11. If you no longer want to allow scripts to run on your computer, you can run the optional command mentioned in the steps.
Open Start on Windows 11.
Search for PowerShell, right-click the top result, and select the Run as administrator option.
Type the following command to confirm the current execution policy and press Enter:
Get-ExecutionPolicy
(Optional) Type the following command to view the effective PowerShell execution policies and press Enter:
Get-ExecutionPolicy -List
Type the following command to change the PowerShell execution policy to allow scripts to run on Windows 11 and press Enter:
Set-ExecutionPolicy RemoteSigned
(Optional) Type the following command to change the execution policy to prevent scripts from running and press Enter:
Set-ExecutionPolicy Restricted
If you want to change the execution policy to run scripts for the current user or local computer, you need to use the “Scope” option like this: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser or Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine.
On Windows 11, you can choose from four different execution policies to allow or deny scripts:
- Restricted — blocks any script from running.
- RemoteSigned — allows scripts created on the computer. However, scripts created on another device won’t run unless they have a trusted signature.
- AllSigned — allows all scripts to run. However, only if a trusted publisher has included a signature.
- Unrestricted — runs any script without restrictions.
You don’t need to change the execution policy if you need to run a script that does not have the required parameters and does not return output. Instead, you can use the PowerShell.exe -File “FILENAME” -ExecutionPolicy Bypass command to bypass the restrictions.