skip to content
vvhybe
the blog

, a 2-minute read

firebase, powershell and the execution policy

firebase login fails in PowerShell because Windows won't run the script npm installed. Don't turn the check off: run the .cmd, loosen it for your account only, or sign the script yourself.

Install the Firebase CLI on Windows and run it from PowerShell:

npm install -g firebase-tools
firebase login

and PowerShell refuses, with something like “running scripts is disabled on this system”. npm installed the command as firebase.ps1, a script, and PowerShell's execution policy won't run it. On Windows the default policy is Restricted: no scripts at all. That's the check doing its job.

The usual fix online is Set-ExecutionPolicy Unrestricted. It works, and it turns the check off for every script, from anywhere. There are three better ways.

the quick one: the .cmd

npm installs each global command for Windows twice: as a PowerShell script and as a .cmd file. The .cmd never goes through the policy:

firebase.cmd login

the usual one: RemoteSigned, for you

RemoteSigned runs the scripts made on your machine and asks for a signature on the ones downloaded from the internet. It's the default on Windows Server, and npm's scripts are made on your machine, so they run. Set it for your account only:

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

the strict one: sign the script

If you'd rather run nothing unsigned, that's AllSigned, and this script needs a signature of yours. Make a certificate, trust it, sign the script:

# a code-signing certificate, for your account only
$cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=My scripts" -CertStoreLocation Cert:\CurrentUser\My

# trust it: as a root, so the signature is valid, and as a publisher, so it runs without asking
Export-Certificate -Cert $cert -FilePath "$env:TEMP\my-scripts.cer"
Import-Certificate -FilePath "$env:TEMP\my-scripts.cer" -CertStoreLocation Cert:\CurrentUser\Root
Import-Certificate -FilePath "$env:TEMP\my-scripts.cer" -CertStoreLocation Cert:\CurrentUser\TrustedPublisher

# sign the script npm installed, and run only signed scripts from now on
Set-AuthenticodeSignature -Certificate $cert -FilePath "$env:APPDATA\npm\firebase.ps1"
Set-ExecutionPolicy -Scope CurrentUser AllSigned

Windows asks you to confirm when the certificate goes into Root: you're trusting a certificate you made yourself. In the first version of this post I did those steps through the Control Panel; the commands do the same.

First published on dev.to, 25 September 2023; rewritten here, 24 November 2026. The original, on dev.to