0

I downloaded angular, but running any command, such as ng v or ng new my-app, throw an error: ng.ps1 cannot be loaded because running scripts is disabled on this system.

There's a question on the matter on Stackoverflow, and the consensus is just to let to remove any restriction by running this command Set-ExecutionPolicy -ExecutionPolicy Unrestricted.

Since it's an old question, I found this on Microsoft docs. I run Get-Item ng.ps1 | Unblock-File as suggested by the documentation Yet it still not working [see below screenshot].

enter image description here

EDIT

enter image description here

Richard77
  • 20,343
  • 46
  • 150
  • 252
  • `Unblock-File` only causes that your file is no longer seen as an internet file but the execution policies still apply. So, how is the execution policy set ([`Get-ExecutionPolicy`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-executionpolicy#:~:text=The%20Get%2DExecutionPolicy%20cmdlet%20shows,script%20isn't%20digitally%20signed.))? Or try: `PowerShell.exe -ExecutionPolicy Bypass -File "C:\tmp\script.ps1"` – iRon Jan 30 '22 at 08:12
  • I run the command you provided. I can't really tell where the content shown in the screenshot is coming from. However, if I try to run `ng v` again, I'm still getting the same: `ng.ps1 cannot be loaded because running scripts is disabled on this system.` – Richard77 Jan 30 '22 at 08:43
  • Try running the command from the `cmd` prompt. – iRon Jan 30 '22 at 09:13
  • Seen your edit, which actually means you able to execute scripts like this. So, you just need to put the right commands in `ng.ps1` or directly invoke the commands like: `PowerShell.exe -ExecutionPolicy Bypass -Command ng v` – iRon Jan 30 '22 at 09:50
  • 1
    Does this answer your question? [PowerShell says "execution of scripts is disabled on this system."](https://stackoverflow.com/search?q=Powershell+policy+execution) – iRon Jan 30 '22 at 10:19

0 Answers0