PowerShell script blocked or won't run β
Question β
I pasted a Invoke-WebRequest ... | Invoke-Expression line (or another .ps1) and PowerShell says the script is disabled, blocked, or cannot be loaded. How do I fix it?
Answer β
Solution 1: β
Execution policy (common error text)
PowerShell may show: running scripts is disabled on this system.
Option A current user only (safest scope):
Open PowerShell (does not have to be Administrator) and run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserConfirm with Y if prompted. RemoteSigned allows local scripts to run and requires downloaded scripts to be signed by a trusted publisher (or unblocked see below).
To see current policies:
Get-ExecutionPolicy -ListSolution 2: β
File marked as downloaded from the internet
If you saved a script as a file, unblock it:
Unblock-File -Path 'C:\Path\To\YourScript.ps1'Or in File Explorer: right-click the file β Properties β check Unblock at the bottom β OK.
Solution 3: β
SmartScreen when running a file
If Windows shows Windows protected your PC, you only see that when running a downloaded executable or script file not usually for a one-line iex from a URL. If you trust the publisher, click More info β Run anyway. Do this only for sources you trust.
4. Run from an elevated shell when the guide says so β
Some steps require Run as administrator. Right-click PowerShell or Terminal β Run as administrator, then paste the command again.
5. Antivirus or corporate policy β
Third-party antivirus or MDM / Group Policy can block script execution regardless of ExecutionPolicy. Temporarily check the AV quarantine or ask the administrator if this is a managed PC.
Security note: Invoke-Expression (iex) runs whatever the remote script returns. Only use URLs and publishers you trust; lowering security globally to βrun everythingβ is a bad tradeoff for a one-time fix.