Unblocking Files with PowerShell
I’ve finally found a use for PowerShell! I don’t really use scripting languages very much, however I’ve recently started a new job and as part of that I found a task that PowerShell seems to be the best tool for.
While setting up my machine I was sent a large number of files. What I didn’t realise at the time was that they were blocked by Windows. This only came to light when things weren’t working as expected. It’s easy to unblock a single file manually, you just go into its properties and tick a box — job done. The problem was that I had thousands of files in a folder that I needed to do this for. Thankfully I came across this command.
dir "c:\SomeDir" -Recurse | Unblock-File
This needs to be run from PowerShell, so I just opened a PowerShell command line and a few seconds later all my files were unblocked. I found this pretty impressive especially as I couldn’t see any shorter way of doing it.