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

Problem:
On trying to run a PowerShell script from 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 http://go.microsoft.com/fwlink/?LinkID=135170."
running scripts is disabled on this system
This is due to the PowerShell's policy to prevent untrusted scripts which can affect your Server environment.

Solution:
  • 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

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.