Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shmuel-raichman/08ae89cbc9c174f984c132298a758bc7 to your computer and use it in GitHub Desktop.
Save shmuel-raichman/08ae89cbc9c174f984c132298a758bc7 to your computer and use it in GitHub Desktop.
create FW rules from a list of exe files (in this case razer)
# B"H
$execListFile = "C:\...\powershell\exe-list.txt"
$ruleBaseName = "block-razer-"
foreach($line in Get-Content $execListFile){
$exeName = [System.IO.Path]::GetFileNameWithoutExtension($line)
$ruleName = $ruleBaseName + $exeName
Write-Host "Creating rule: $ruleName"
Write-Host "Program path: $line"
New-NetFirewallRule -DisplayName $ruleName -Direction Inbound -Program $line -Action Block
New-NetFirewallRule -DisplayName $ruleName -Direction Outbound -Program $line -Action Block
}
# To get a list of exe files for diractory
# Run this in WSL (bash for windows)
# cd /mnt/c/YOUR_PATH
# find . -name *.exe > exe-list.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment