Unblocking Download Files

by Jan 22, 2014

Any file you download from the Internet or receive via email get marked by Windows as potentially unsafe. If the file contains executables or binaries, they will not run until you unblock the file.

PowerShell 3.0 and better can identify files with a "download mark":

Get-ChildItem -Path $Home\Downloads -Recurse |
  Get-Item -Stream Zone.Identifier -ErrorAction Ignore | 
  Select-Object -ExpandProperty FileName |
  Get-Item  

You may not receive any files (if there are none with a download mark), or you may get tons of files (which can be an indication that you unpacked a downloaded ZIP file and forgot to unblock it before).

To remove the blocking, use the Unblock-File cmdlet. This would unblock all files in your download folder that are currently blocked (not touching any other files):

Get-ChildItem -Path $Home\Downloads -Recurse |
  Get-Item -Stream Zone.Identifier -ErrorAction Ignore | 
  Select-Object -ExpandProperty FileName |
  Get-Item |
  Unblock-File 

Twitter This Tip! ReTweet this Tip!