# Add to $PROFILE function ub Get-ChildItem -Path $args[0] -File -Recurse Set-Alias -Name unblock-all -Value ub Then simply use:
Write-Host "Scanning: $targetPath" -ForegroundColor Cyan recursively unblock files powershell
# Get all files recursively $files = Get-ChildItem -Path $targetPath -File -Recurse -ErrorAction SilentlyContinue # Add to $PROFILE function ub Get-ChildItem -Path
unblock-all "C:\Downloads" This feature is useful for safely handling downloaded files that Windows marks with an alternate data stream (Zone.Identifier) to indicate they came from the internet. recursively unblock files powershell
# Filter by extensions if specified if ($IncludeExtensions.Count -gt 0) Where-Object $IncludeExtensions -contains $_.Extension.TrimStart('.')
foreach ($file in $files) try # Check if file has zone identifier (downloaded from internet) $stream = $file.GetAccessControl() $hasZoneId = (Get-Item $file.FullName -Stream * -ErrorAction SilentlyContinue catch Write-Warning "Failed to unblock: $($file.FullName) - $_"
$unblockedCount = 0