Enable PowerShell Scripting on Windows 10/11

PowerShell script execution is disabled by default on Windows 10 and 11. If you try to run a script, you receive the error:

File c:\scripts\MyScript.ps1 cannot load because the execution of scripts is disabled on this system.

Script execution permissions are governed by a series of different policies that you can choose from per Microsoft's PowerShell Execution Policies document. The ones we're interested in are:

  • Restricted prevents any PowerShell scripts from being executed. This is the default.
  • Unrestricted allows any PowerShell script to execute, whether signed or not. This is the most convenient, but you should set this if the computer is accessed ONLY by trusted users.

To change the execution policy, open a PowerShell session "as Administrator" to gain proper permissions and execute the command:

Set-ExecutionPolicy Unrestricted

You will receive a confirmation prompt that you want to perform this action. Press Y and Enter to confirm, and PowerShell script execution is now enabled.