serving the solutions day and night


Tuesday, November 7, 2017

PowerShell – running scripts is disabled on this system.

When i execute powershell script from Windows PowerShell ISE, i got error, means PowerShell execution policy doesn't allow to run script.

File TaskYearApp.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess

First i want to see what's my execution policy settings, i run the below commands

PS G:\> get-executionpolicy

So PowerShell execution policy is default set to Restricted.

PS G:\> get-executionpolicy -List

  Scope                    ExecutionPolicy
  ---------------       ----------------
  MachinePolicy       Undefined
 UserPolicy              Undefined
 Process                   Undefined
 CurrentUser            Undefined
 LocalMachine         Undefined
 List of four different execution policies in PowerShell

  Restricted – No scripts can be run.
  AllSigned – Only scripts signed by a trusted publisher can be run.
  RemoteSigned – Downloaded scripts must be signed by a trusted publisher.
  Unrestricted – All Windows PowerShell scripts can be run.

Workaround solution is, you can change the PowerShell execution policies with Set-ExecutionPolicy cmdlet. Run PowerShell as administrator, Give it the remote signed execution policy which allows to execute that script

PS G:\> powershell -ExecutionPolicy RemoteSigned
- it will take time to set the policy


PS G:\> Set-ExecutionPolicy RemoteSigned 

No comments: