Last active
April 3, 2023 02:14
-
-
Save ilsubyeega/f3257879c6987821801b5b43da02313b to your computer and use it in GitHub Desktop.
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
| $content = Get-Content .\Desktop\list.txt.txt | |
| $content = $content.Trim() | |
| foreach ($item in $content.Split("`n")) | |
| { | |
| if ($null -eq $item -or $item.Length -eq 0) { return } | |
| $splitted = $item.Split("|") | |
| $rule_name = $splitted[0].Trim() | |
| $rule_location = $splitted[1].Trim() | |
| New-NetFirewallRule -DisplayName $rule_name -Direction Inbound -Program $rule_location -Action Block | |
| New-NetFirewallRule -DisplayName $rule_name -Direction Outbound -Program $rule_location -Action Block | |
| Write-Host "Successfully add rule" $rule_name "(" $rule_location ")" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment