Last active
March 30, 2024 16:02
-
-
Save sad1e/cf1cdf63a4247033ecebeb8c22c04182 to your computer and use it in GitHub Desktop.
script to add exe files to firewall outbound rules.
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
| param( | |
| [string]$DestPath = "", | |
| [string]$GroupName = "" | |
| ) | |
| if ([string]::IsNullOrEmpty($DestPath)) { | |
| Write-Host "Destinationpath path is empty."; | |
| return; | |
| } | |
| if (![System.IO.Directory]::Exists($DestPath)) { | |
| Write-Host "Destination path is not exists." | |
| return; | |
| } | |
| if ([string]::IsNullOrEmpty($GroupName)) { | |
| Write-Host "GroupName is empty." | |
| return; | |
| } | |
| $ExeFiles = Get-ChildItem -Path $DestPath -Recurse -Filter *.exe | |
| foreach ($ExeFile in $ExeFiles) { | |
| New-NetFirewallRule -Action Block -Program $ExeFile.FullName -Direction Outbound -Group $GroupName -DisplayName "$GroupName-$($ExeFile.BaseName)" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment