Use PowerShell to unblock files on Windows

When you save files, such as a PDF or a ZIP file, from a remote location (eg from the internet), Windows tries to protect our machine by blocking it using the Alternate Data Streams (ADS) technology.

To check if a file is blocked, just look at its properties, as shown in the picture below. From here, you can unblock it.

Use PowerShell to unblock files on Windows

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

But what if you want to unblock more than one file in one folder? As long as you know that there is no security issue for these files, you can unblock them all with the help of PowerShell.

Unblock files in a folder using PowerShell

Type the following command to unblock all files in a folder by changing the path of the folder to yours.

Get-ChildItem -Path 'C:\Users\Dimitris\Downloads\' | Unblock-File

Or for a shortcut, try the following.

gci 'C:\Users\Dimitris\Downloads \' | Unblock-File

If you want to unblock all files that exist in the sub-folders as well, just add the -Recurse switch.

Get-ChildItem -Path 'C:\Users\Dimitris\Downloads\' -Recurse | Unblock-File

More about Unblock-File.

About Dimitris Tonias 144 Articles
My name is Dimitris Tonias, IT Pro, G(r)eek, focused on Server, Virtualization, and Cloud technologies.

6 Comments on Use PowerShell to unblock files on Windows

  1. Very helpful. Thank you.

    I have one question. Is there a way to list the files that need unblocking? This way I can review that list first.

    • You can use PowerShell to get all these files for review. For example, running the following command you will get the list of all files that needs unblocking. Zone identifier stores whether the file was downloaded from the internet.

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

  2. I know this is an old post but it just helped me a lot today. 45 years old and I learned something new. Just saved me time cause I just unzipped a 3 gb file I forgot to unblock before. Thanks!

Leave a Reply

Your email address will not be published.