Renaming Windows Firewall Rules with PowerShell

I had some rules that were set by default that were not “user friendly” so I wanted to rename them in order to be able to tell what they were without having to query.

I can use Get-FirewallRule with some parameters to see the rules in question:

get-netfirewallrule -displaygroup "remote desktop" | format-table name, enabled -autosize
Use get-netfirewallrule to view the current firewall rules
Use get-netfirewallrule to view the current firewall rules

Then I Mark (right click, “Mark”, select and press the “Enter” key to copy to clipboard) the GUID and get the name of that rule to see what it is:

Get-NetFirewallRule -Name {4F5F06CB-CA8A-4676-BDB3-4BBBC8E95481}
Viewing the details of the firewall rule in question
Viewing the details of the firewall rule in question

Then I rename the rule using the Rename-FirewallRule cmdlet, and query again to see the change:

rename-netfirewallrule -name "{GUID}" -newname "New name of firewall rule"
get-netfirewallrule -displaygroup "remote desktop" | format-table name, enabled -autosize
Renaming the firewall rule to match the DisplayName attribute
Renaming the firewall rule to match the DisplayName attribute

As it turns out, these rules are duplicates of the ones above – the only difference that I found was that they apply to different profiles. The rules with “user friendly” names were for the “Public” Firewall Profile, whereas the GUID rules were for “Domain” and “Private” Firewall Profiles. This is the way the Remote Desktop rules are added when you configure Remote Administration with sconfig. This relates to my previous post on “Installation Configuration: Hyper-V Server 2012“.

Differences between the builtin rule and the rule created when using sconfig
Differences between the builtin rule and the rule created when using sconfig

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *