Last active
March 30, 2024 16:02
-
-
Save sad1e/cf1cdf63a4247033ecebeb8c22c04182 to your computer and use it in GitHub Desktop.
Revisions
-
sad1e revised this gist
Mar 30, 2024 . No changes.There are no files selected for viewing
-
sad1e created this gist
Mar 30, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ 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)" }