Unblock-File
Allow a downloaded script to run
Unblock-File -Path .\script.ps1
- Works on
- WindowsmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Unblock-File
- PowerShell 7 Also works on macOS, where it removes the quarantine mark from downloaded files. Not available on Linux.
When you download a file, Windows tags it as coming from the internet. Under the usual RemoteSigned execution policy, PowerShell refuses to run a tagged .ps1 and says it "is not digitally signed."
Unblock-File removes that tag. It does not change your execution policy, and it only affects the files you name.
Read the script before you unblock it. The tag is there to make you stop and look.
Common parameters
-Pathtakes wildcards, so.\*.ps1unblocks every script in the folder.-WhatIfshows which files it would unblock.
Try this
Get-ChildItem -Path .\downloads -Filter *.ps1 | Unblock-File -WhatIf
You can also right-click the file in Explorer, choose Properties, and tick Unblock.