- To change the PowerShell execution policy, open PowerShell (admin) and run the “Set-ExecutionPolicy RemoteSigned” command to set execution to allow scripts. The “Set-ExecutionPolicy AllSigned” command allows scripts from trusted publishers. Or the “Set-ExecutionPolicy Unrestricted” command allows scripts without restrictions.
- You can also run the “Set-ExecutionPolicy Restricted” to undo the changes and prevent scripts from running.
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 has 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 configure 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 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 PowerShell execution policy on Windows 11
To change the PowerShell execution policy 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:
(Optional) Type the following command to view the effective PowerShell execution policies and press Enter:
Type the following command to change the PowerShell execution policy to allow scripts to run on Windows 11 and press Enter:
(Optional) Type the following command to change the execution policy to prevent scripts from running and press Enter:
Once you complete the steps, you can execute the script again, 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.
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 file from running.
- RemoteSigned — allows scripts to be created on the computer. However, scripts created on another device won’t run without 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.