File *.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.

Error:-

PS D:\> .\ScriptKeys.ps1
File D:\ScriptKeys.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.
At line:1 char:17
+ .\ScriptKeys.ps1 <<<<
+ CategoryInfo          : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException

Fix:-

PS D:\> Set-ExecutionPolicy Unrestricted

Error:-
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is “Y”): y
Set-ExecutionPolicy : Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft
.PowerShell’ is denied.
At line:1 char:20
+ Set-ExecutionPolicy <<<<  Unrestricted
+ CategoryInfo          : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

Fix:-

Run the power shell as Administrator and re run the below to fix both the errors above:

Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy RemoteSigned

This entry was posted in PowerShell, Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply