While setting up a new computer, Windows was throwing up warnings that files transferred from a backup drive might be unsafe. The files were text and images, so the warnings were safe to ignore but the directory had over one thousand files. Rather than unblocking each file manually, Windows PowerShell makes it easy to unblock files in bulk.
Load up Windows Powershell:
- Press Win + R on the keyboard to open the Run dialog.
- In the Run box, type powershell
For one folder without subdirectories, this snippet will do the trick.“$env:userprofile\Downloads“ tells PowerShell to use the Download folder for the logged in user and unblocks all files in it. Change this to the folder path you need if it’s not the Downloads folder.
get-childitem “$env:userprofile\Downloads“ | unblock-file
If you have sub-directories and need to unblock everything, use the -Recurse flag:
dir “$env:userprofile\Downloads“ -Recurse | Unblock-File
Want to see a report of files to be unblocked before running it? The -WhatIf flag will show you without executing.
dir “$env:userprofile\Downloads“ -Recurse | Unblock-File -WhatIf