Fail to run Altostra CLI commands from Windows PowerShell
Problem
Running any alto
command results in a following security error:
alto : File C:\Users\WDAGUtilityAccount\AppData\Roaming\npm\alto.ps1 cannot be loaded because 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
+ alto --version
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Cause
PowerShell's execution policy is a safety feature that controls the conditions under which PowerShell runs scripts.
On Windows, the default execution policy is Restricted
, which permits individual commands,
but does not allow scripts and prevents running of all script files, including formatting
and configuration files (.ps1xml
), module script files (.psm1
), and PowerShell profiles (.ps1
).
For more information please follow this link.
Resolution
In order to execute alto
commands (and other programs downloaded by npm
) you must
change PowerShell's execution policy so it allows to run scripts.
To do so, please execute the following command:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force