Different ways to unblock file with PowerShell


When you download a PowerShell script/zip file from Internet and you try to run it, you’ll get a warning message like this one :Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning message. Do you want to run C:TempExport-MailboxesStatistics.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is “D”):

This is  due to a security feature of Windows. Each file downloaded from Internet is tagged, you can check it :


If you click on “Unblock”, you’ll be able to run the script. But, if you download a bunch of them, it can be time consuming, so you need a PowerShell solution.

#Solution 1
Get-ChildItem C:Temp *.ps1 -Recurse | Unblock-File
#Solution 2
Get-ChildItem C:Temp *.ps1 | Foreach-Object { Remove-Item $_.Name -Stream Zone.Identifier -ErrorAction Ignore }



0 thoughts on “Different ways to unblock file with PowerShell

  1. Pingback: Fun with AD Custom Attributes: Storing User Logon and Hardware Information on the AD Computer Object

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.