$files = Get-ChildItem -Path $Path -Recurse -File $blockedFiles = @()
param( [Parameter(Mandatory=$false)] [string]$Path = ".", [Parameter(Mandatory=$false)] [switch]$WhatIf, get-childitem -recurse -file | unblock-file
if ($Confirm -and $blockedFiles.Count -gt 0) $response = Read-Host "Unblock these $($blockedFiles.Count) files? (Y/N)" if ($response -ne 'Y') return get-childitem -recurse -file | unblock-file
[Parameter(Mandatory=$false)] [switch]$Confirm ) get-childitem -recurse -file | unblock-file
Usage:
foreach ($file in $files) $hasZone = Get-Item $file.FullName -Stream Zone.Identifier -ErrorAction SilentlyContinue if ($hasZone) $blockedFiles += $file
Write-Host "Found $($blockedFiles.Count) blocked files" -ForegroundColor Cyan