New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
[SOLVED] Need powershell help - adding IPs (scope) in three firewall rules (Windows 2016)
Hello, I need somebody smart guy (or girl if they exist here on LET ) that can help me with a task. Every time I install a new server, I have to edit three firewall rules, adding 4 IPs to each rule. (Scope -->Remote address) I'm sure this could easily been done with a PowerShell script.
The three rules I have to edit is:
RemoteDesktop-UserMode-In-TCP
RemoteDesktop-UserMode-In-UDP
VIRT-REMOTEDESKTOP-In-TCP-NoScope
Anybody just know what commands to use so I can make me a script, saving me from using the rest of this fine Saturday reading and searching google after the right guide.
Comments
It was pretty simple, this script do the trick (can maybe be cleaned up some)
$name = Get-NetFirewallrule -DisplayName "Hyper-V (REMOTE_DESKTOP_TCP_IN)"
$ips = @("1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4", "1.1.1.5")
foreach($r in $name)
{
Set-NetFirewallRule -DisplayName $r.DisplayName -RemoteAddress $ips
}
$name = Get-NetFirewallrule -DisplayName "Remote Desktop - User Mode (TCP-In)"
foreach($r in $name)
{
Set-NetFirewallRule -DisplayName $r.DisplayName -RemoteAddress $ips
}
$name = Get-NetFirewallrule -DisplayName "Remote Desktop - User Mode (UDP-In)"
foreach($r in $name)
{
Set-NetFirewallRule -DisplayName $r.DisplayName -RemoteAddress $ips
}
# Disable rules
Disable-NetFirewallRule -Name RemoteDesktop-Shadow-In-TCP