Skip to content

Instantly share code, notes, and snippets.

@jumoog
Created September 15, 2025 10:56
Show Gist options
  • Save jumoog/5f578a775508335f1548edc7141018f2 to your computer and use it in GitHub Desktop.
Save jumoog/5f578a775508335f1548edc7141018f2 to your computer and use it in GitHub Desktop.
block all exe files in a folder recursive
Get-ChildItem -Path "C:\Path\" -Filter *.exe -Recurse |
Select-Object Name, FullName |
ForEach-Object {
New-NetFirewallRule -DisplayName "Block $($_.Name) Inbound" -Direction Inbound -Program "$($_.FullName)" -Action Block
New-NetFirewallRule -DisplayName "Block $($_.Name) Outbound" -Direction Outbound -Program "$($_.FullName)" -Action Block
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment