Commands / Help and discovery

Unblock-File

Allow a downloaded script to run

beginner Help and discovery

Unblock-File
 Unblock-File -Path .\script.ps1
Works on
WindowsmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Unblock-File

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

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.

Related commands