404 Tech Support

How to ‘Unblock’ multiple files at a time with PowerShell

If you have been frustrated by the warning message on Windows computers “This file came from another computer and might be blocked to help protect this computer.”, you are not alone. The warning might pop up when you try to open a file that you downloaded from the Internet. It can cause a decent amount of frustration because of the way it is implemented.

If you right-click on a single file and choose Properties, you can see the Security section at the bottom of the window.

“This file came from another computer and might be blocked to help protect this computer.”

You can check the box (in Windows 10) or click the Unblock button (in Windows 7/8) to unblock the file. However, if you have multiple files, you cannot select more than one and view the properties to unblock all of the files at once. Instead, you will have to check each file separately and unblock them one at a time. One tip was to always unblock a zip file before extracting it for this reason.

You can disable the setting through Group Policy by enabling the setting ‘Do not preserve zone information in file attachments’ found under User Configuration -> Administrative Templates -> Windows Components -> Attachment Manager. I don’t recommend this as I prefer to keep security warnings in place. I previously dealt with this several years ago when a script had problems running a blocked file where the solution was to add a UNC path of the file to the Trusted Sites Intranet zone.

Microsoft has a command line utility called ‘streams’ that you can download and tell it to remove the NTFS-attached data stream that identifies a file as downloaded from the Internet. The command for this is streams -s -d [directory path]. Nirsoft also has a utility called Alternate Data Streams with similar functionality.

Rather than having to download a separate executable, there is native PowerShell functionality that will allow us to unblock multiple files at a time. The command is:

dir -Path [directory path] -Recurse | Unblock-File

This command will recurse through a directory and all sub-folders and unblock them. If you have a few files that you trust but were downloaded from the Internet, you can quickly get them all by sticking them in a folder and running that PowerShell command on them to have the stream property removed. It certainly beats the weird issues that can be caused by this setting and weird workarounds to zip the files up, unblock the zip and then extracting the files again.