How to change execution policy to run scripts on PowerShell

If you're getting an error running a PowerShell script, it's because you need to change the execution policy, and here's how.

Windows 11 change PowerShell execution policy
Windows 11 change PowerShell execution policy
  • 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:

  1. Open Start on Windows 11.

  2. Search for PowerShell, right-click the top result, and select the Run as administrator option.

  3. Type the following command to confirm the current execution policy and press Enter:

    Get-ExecutionPolicy
  4. (Optional) Type the following command to view the effective PowerShell execution policies and press Enter:

    Get-ExecutionPolicy -List
  5. Type the following command to change the PowerShell execution policy to allow scripts to run on Windows 11 and press Enter:

    Set-ExecutionPolicy RemoteSigned
  6. (Optional) Type the following command to change the execution policy to prevent scripts from running and press Enter:

    Set-ExecutionPolicy Restricted

    PowerShell change execution policy

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.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 14 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].