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

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay