TL;DR: PowerShell: “running scripts is disabled on this system” (execution policy)
The fix only. No explanation, no diagnosis. Read the full article if any of this does not match what you are seeing.
- See which scope is setting the policy (read the list top to bottom).
Get-ExecutionPolicy -ListIf MachinePolicy or UserPolicy shows anything other than Undefined, Group Policy is setting it. No local command will override it. Talk to whoever manages Group Policy.
- Run one script once, without changing any setting:
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\script.ps1- Allow local scripts for your account only (no admin needed):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser- For everyone on the machine, from an elevated PowerShell:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine- If the message says the file "is not digitally signed", it was downloaded and is marked as blocked. Read the script, then unblock that one file:
Unblock-File -Path .\script.ps1- Verify with
Get-ExecutionPolicy -List, then run the script.
Do not use Unrestricted or edit the registry by hand. RemoteSigned for your user is enough for nearly everything.