Fix for PowerShell Script cannot be loaded because running scripts is disabled on this system error

Problem: Getting “cannot be loaded because running scripts is disabled on this system” error!

On trying to run a PowerShell script from the PowerShell console, received this error message: “File C:\temp\GenerateRpt.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.”

cannot be loaded because running scripts is disabled on this system

Root Cause: This is due to PowerShell’s policy to prevent untrusted scripts which can affect your Server environment.

Solution for “cannot be loaded because running scripts is disabled on this system:

To fix this issue, we have to set the execution policy, so that the PowerShell script runs on the particular machine. Here is how:

  • Open PowerShell Console by selecting “Run as Administrator” and set the execution Policy with the command: Set-ExecutionPolicy RemoteSigned
  • Type “Y” when prompted to proceed 

This in fact sets the registry key: HKLM\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
Policy parameter takes below values:

  1. Restricted – No scripting allowed
  2. Unrestricted – You can any scripting
    • No signing required
  3. Remote signed – good for Test, Dev environments
    • Only files from internet need to be signed
    • This is the default setting
  4. All signed  – local, remote script, it should be signed.
    • user must agree to run script
Fix for PowerShell Script cannot be loaded because running scripts is disabled on this system error

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

4 thoughts on “Fix for PowerShell Script cannot be loaded because running scripts is disabled on this system error

Leave a Reply