Error After Installing Salesforce CLI on PowerShell Using npm

After installing Salesforce CLI on Windows PowerShell using npm, you get a security policy error whenever you try to execute any CLI command. Installing with the Windows-specific installer works correctly.

The error looks something like this:

1sf : File C:\Users\<username>\AppData\Roaming\npm\sf.ps1 cannot be loaded because running scripts is disabled on this system

The problem is that you have a PowerShell execution policy configured for your computer that’s blocking Salesforce CLI from working correctly.

To fix the error, work with your administrator to manage the policy settings on your computer to disable the one that's blocking Salesforce CLI. For more information, see about_Execution_Policies in the Microsoft PowerShell documentation.