Last active
June 14, 2022 14:01
-
-
Save peetrike/4636036304bfd2bb598a69d2eb31d49f to your computer and use it in GitHub Desktop.
Create address filter for reaching remote server, if it's network connection is Public
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
#Requires -Modules NetSecurity | |
# Remote admin network | |
$RemoteNet = '1.2.3.4/255.255.255.248' | |
$AddressFilter = Get-NetFirewallRule -Group '@FirewallAPI.dll,-30267' | | |
Where-Object Profile -like 'Public' | | |
Get-NetFirewallAddressFilter | |
if ($AddressFilter.RemoteAddress -NotContains $RemoteNet) { | |
$remoteFilter = @($AddressFilter.RemoteAddress) + $RemoteNet | |
$AddressFilter | Set-NetFirewallAddressFilter -RemoteAddress $remoteFilter | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment