brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Unblock-File clears the Windows internet mark on a downloaded script

Windows
~/tips/tip-windows-unblock-file-downloads

Get-Item * -Stream Zone.Identifier -ErrorAction SilentlyContinue

Run a downloaded PowerShell script you checked, without loosening the execution policy.

A script you download can refuse to run with a message that it isn’t digitally signed. Windows tagged the file as coming from the internet, and the RemoteSigned policy blocks tagged scripts that are unsigned.

You can see which files in a folder carry the mark:

Get-Item * -Stream Zone.Identifier -ErrorAction SilentlyContinue

Read the script first. Once you’re happy with what it does, remove the mark from that one file:

Unblock-File -Path .\setup.ps1

The cmdlet deletes the Zone.Identifier stream, the same thing the Unblock button in the file’s Properties dialog does. It prints nothing when it works, and running it on a file that wasn’t blocked does no harm. If you want a preview, add -WhatIf.

I much prefer this over changing the execution policy for the whole machine just to get one script running.

Please don’t pipe a whole Downloads folder into it. The mark exists to make you stop and look, and unblocking in bulk throws that away. Also keep in mind that files fetched with curl.exe or Invoke-WebRequest may not get the mark at all, so a script without it isn’t automatically trustworthy.

Further reading: Unblock-File, about_Execution_Policies

More Windows tips Win+Ctrl+C Win+Shift+Left arrow Win+Ctrl+Left arrow Alt+PrtScn Left Alt + Left Shift + Print Screen All Windows tips (33) All topics

Link