Fix PowerShell - .ps1 cannot be loaded because running scripts is disabled on this system

Error:

PS C:\Users\Code2care\Desktop> my-ps-script.ps1

C:\Users\Code2care\Desktop\my-ps-script.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.

...

+ CategoryInfo :SecurityError: (:) LJ, PSSecurityException

+ FullyQualifiedErrorId : UnauthorizedAccess

One of the major reasons for the PowerShell script cannot be loaded error is that the script that is being tried to be executed is not signed.

The other reason could be that the PowerShell execution policy is set to "Restricted" or "AllSigned" on your Windows OS (8/9/10/11) or Server.


Ways to fix the error:

  • Make sure you are running the PowerShell Script as an administrator, right click on the .psq file and select "Run as Administrator".
  • Make sure the script is not blocked, to unblock right-clicking on the .ps1 script file, select "Properties" -> "Unblock" button in the "General" tab.
  • Set the Execution Policy to RemoteSigned

    - Run PowerShell as an administrator.

    - Run the command: Set-ExecutionPolicy RemoteSigned

    Try running the script again and it should work if the script is signed by a trusted publisher.

  • If the above steps do not work you will need to get the script initially signed to make sure you can run it without changing the Execution Policy.

    Comments & Discussion

    Facing issues? Have questions? Post them here! We're happy to help!