Skip to content

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:

powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Confirm 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:

powershell
Get-ExecutionPolicy -List

Solution 2: ​

File marked as downloaded from the internet

If you saved a script as a file, unblock it:

powershell
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.