Created
December 22, 2020 10:41
-
-
Save AgentRev/a4f93dcca1dc27c72963b36f3b345820 to your computer and use it in GitHub Desktop.
Removes orphaned entries from the Windows Firewall.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# firewall_cleanup.ps1 | |
# | |
# Removes orphaned entries from the Windows Firewall. | |
# | |
$rules = Get-NetFirewallApplicationFilter | Where {($_.Program -ne "Any") -and ($_.Program -ne "System") -and (-not (Test-Path ([Environment]::ExpandEnvironmentVariables($_.Program))))} | Get-NetFirewallRule | |
foreach ($rule in $rules) | |
{ | |
Write-Host "REMOVING RULE:" $rule.Direction "-" $rule.DisplayName | |
Remove-NetFirewallRule -InputObject $rule #-WhatIf | |
} | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment