Powershell Unblock - All Files In Folder

.\Unblock-Folder.ps1 -FolderPath "C:\MyFolder" -Recurse Before unblocking, check if a file has the Zone.Identifier stream:

$files = Get-ChildItem -Path $FolderPath -File -Recurse:$Recurse powershell unblock all files in folder

ls "C:\Downloads" -File | Unblock-File Get-ChildItem -Path "C:\Downloads" -File -Recurse | Unblock-File 4. Unblock Only Specific File Types (e.g., .ps1 and .exe ) Get-ChildItem -Path "C:\Downloads" -Recurse -Include *.ps1, *.exe | Unblock-File 5. Dry Run with -WhatIf Get-ChildItem -Path "C:\Downloads" -File | Unblock-File -WhatIf This shows which files would be unblocked without actually changing them. Complete Script Example Save the following as Unblock-Folder.ps1 : powershell unblock all files in folder

if (-not (Test-Path $FolderPath)) Write-Error "Folder does not exist: $FolderPath" exit 1 powershell unblock all files in folder

[switch]$WhatIf )

When you download a PowerShell script and see:

if ($files.Count -eq 0) Write-Host "No files found in $FolderPath" exit