PowerShell execution of scripts is disabled on this system

Issue Description

PowerShell commands the execution of scripts produces an error as below,

ng : File C:\Users\test\AppData\Roaming\npm\ng.ps1 cannot be loaded. The file C:\Users\test\AppData\Roaming\npm\ng.ps1 cannot be loaded because the execution of scripts is disabled on this system. 

Resolving PowerShell execution of scripts is disabled on this system

Resolution

This issue means your machine is preventing you from running of script files. Implementation of these policies occurs on Windows platforms including Windows client or Windows Server machines.

The PowerShell execution policies are as follows,

  • Formatting and configuration files (.ps1xml),
  • Module script files (.psm1), and
  • PowerShell profiles (.ps1).

Steps to resolve the issue

To change the PowerShell execution policy on your Windows computer, use the below command.

Step1: let’s get the current ExecutionPolicy for your Machine using the below command

 Get-ExecutionPolicy -List
Resolving PowerShell execution of scripts is disabled on this system

By Default Current User policy might be set as restricted in your case.

If you using X64 Bit OS, please use the command prompt from the below path,

C:\Windows\system32\cmd.exe

For x86(32 bit)

C:\Windows\SysWOW64\cmd.exe

Step2: Once you know your identity scope and execution policy, please run the below commands using the same.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

The above script shall do the tricks.

Please be cautious to change any execution policy.

Finally, you shall be all set to run your PowerShell script (without restarting the PowerShell).

Resolving PowerShell execution of scripts is disabled on this system

Note: Please run all the above commands as administrator mode

That’s all! Happy coding!

Does this help you fix your issue?

Do you have any better solutions or suggestions? Please sound off your comments below.

References:

Do you have any comments or ideas or any better suggestions to share?

Please sound off your comments below.

Happy Coding !!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *