Click here to Skip to main content
13,139,254 members (85,309 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 3 Oct 2012

Unblock Downloaded Files with PowerShell

, 3 Oct 2012
Rate this:
Please Sign up or sign in to vote.
Unblock downloaded files with PowerShell

Have you ever got into a situation that you downloaded a zip-file and figured out too late that the files are blocked? So you extracted the zip file into a folder with existing items. It will be damn hard to figure out which files needs to be unblocked. Besides that, it will cost you a lot of work to do so by right-clicking all of the files and clicking the unblock button.

Luckily, we have PowerShell and we can easily write a little script to execute the unblock operation on the files in a specific directory. So start by opening PowerShell and key in the following command:

gci  ’c:\Somefolder’ | Unblock-File -WhatIf

The above command will unblock all the Child Items in the given directory. The WhatIf parameter will actually not execute it really, but it will show you what the script is going to do. To really execute the action, you have to remove the parameter.

gci ‘c:\Somefolder’ | Unblock-File

As you may have seen when using the WhatIf parameter, only the files in this folder will be unblocked. What if you want to unblock the files in the sub folders. This can easily be done with the Recurse parameter on your path.

gci ‘c:\Somefolder’ -Recurse | Unblock-File -WhatIf

Because I used the WhatIf parameter again, I can pre-check what the command is actually going to do. When I’m sure I want to do it, I can just remove the WhatIf parameter again and run the script against the files.

gci ‘c:\Somefolder’ -Recurse | Unblock-File

So now you won't have to worry about files being blocked, just execute the script and you’re ready to go. Bookmark this article to easily access the commands when you need them and share it with your friends to make their lives also a little easier. Oh and don’t forget to have a look at the ‘PowerShell Getting Started Guide‘ for more information on using PowerShell.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer Atos
Netherlands Netherlands
I am a .NET Software Developer at Atos International. Architecture, CQRS, DDD, C#, ASP.NET, MVC3, HTML5, Jquery, WP7, WPF, ncqrs, Node.js

You may also be interested in...


Comments and Discussions

QuestionUnknown command Unblock-File Pin
Joel Lucsy3-Oct-12 7:38
memberJoel Lucsy3-Oct-12 7:38 
I'm wondering if you have a cmdlet or something installed for Unblock-File, since my PowerShell doesn't seem to know it.
Joel Lucsy

AnswerRe: Unknown command Unblock-File Pin
William E. Kempf3-Oct-12 9:25
memberWilliam E. Kempf3-Oct-12 9:25 
AnswerRe: Unknown command Unblock-File Pin
Maximilian Haru Raditya4-Oct-12 16:53
memberMaximilian Haru Raditya4-Oct-12 16:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170915.1 | Last Updated 3 Oct 2012
Article Copyright 2012 by marcofranssen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid