DEV Community

Cover image for Window PowerShell: "Running scripts is disabled on this machine"
Emmanuel Aiyenigba
Emmanuel Aiyenigba

Posted on

Window PowerShell: "Running scripts is disabled on this machine"

Hey! I know you are here because you tried running a command (probably the TypeScript command tsc --init) on PowerShell and its throwing you the error below:

running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

  • tsc --init
  • ~~~
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess

or an error similar to this.

Why this error?

The error happened because you are trying to execute a script on your machine without you approving it. For security reasons, Windows will not let that happen.

Solution

The solution to this is to run PowerShell on your machine under administrative rights and enter set-executionpolicy remotesigned. You will be asked Do you want to change execution policy? select yes.

That should solve the problem! Now go back and run the script you had earlier tried to run.

For security reasons, you might want to return the execution policy back to restricted when you are done - set-executionpolicy restricted

Read more about PowerShell execution policies

Discussion (0)