Created
November 17, 2022 23:24
-
-
Save deejayy/9fac4acc1aeefc9289efb7f71c9325df to your computer and use it in GitHub Desktop.
Add exceptions to Windows firewall based on blocked connections
This file contains 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
Get-EventLog -Log Security -Newest 100 -InstanceId 5152 -Message "*%%14593*" | Sort-Object -Property TimeGenerated | Select-Object -ExpandProperty Message | ? { $_ -notlike "*svchost*" } | % { $_ -split "\r\n" } | ? { $_ -like "*Application Name*" -or $_ -like "*Destination*" } | % { $_ -replace "\\device\\harddiskvolume.",":" } | |
$path = Read-Host 'Path: ' | |
$appName = Read-Host 'App name: ' | |
$date = Get-Date -Format "yyyy-MM-dd" | |
Write-Output "XX $appName / $date" | |
New-NetFirewallRule -DisplayName "XX $appName / $date" -Direction Outbound -Program $path -Action Allow | |
-- | |
Runner.bat: | |
@echo off | |
powershell.exe -Command "Start-Process powershell.exe -Verb RunAs D:\bin\batch\addfw.ps1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment