Recursively Unblock Files - Powershell ((link))
function Unblock-FilesRecursively [CmdletBinding()] param( [Parameter(Mandatory=$false, Position=0)] [string]$Path = ".", [Parameter(Mandatory=$false)] [string[]]$IncludeExtensions = @(), [Parameter(Mandatory=$false)] [switch]$WhatIf )
# Get all files recursively $files = Get-ChildItem -Path $targetPath -File -Recurse -ErrorAction SilentlyContinue recursively unblock files powershell
# Resolve the path $targetPath = Resolve-Path $Path -ErrorAction Stop Position=0)] [string]$Path = "."
# Filter by extensions if specified if ($IncludeExtensions.Count -gt 0) Where-Object $IncludeExtensions -contains $_.Extension.TrimStart('.') recursively unblock files powershell
foreach ($file in $files) try Where-Object $_.Name -eq "Zone.Identifier" ) if ($hasZoneId) if ($WhatIf) Write-Host "[WHATIF] Would unblock: $($file.FullName)" -ForegroundColor Yellow else Unblock-File -Path $file.FullName -ErrorAction Stop Write-Host "[UNBLOCKED] $($file.FullName)" -ForegroundColor Green $unblockedCount++ catch Write-Warning "Failed to unblock: $($file.FullName) - $_"
# Add to $PROFILE function ub Get-ChildItem -Path $args[0] -File -Recurse Set-Alias -Name unblock-all -Value ub Then simply use:
$unblockedCount = 0