Script cannot be loaded because the execution of scripts is disabled on this system.

Recently, I’ve got the above error when trying to execute a powershell script.

Reason: By default, PowerShell’s execution policy is set to Restricted; that means that scripts – including those you write yourself – won’t run.

Solution: Temporarely change the execution policy using the following commands.

  1. Set-ExecutionPolicy Unrestricted
  2. Run your powershell script
  3. Set-ExecutionPolicy Restricted