Once again, lets use the new PowerShell cmdlets that ship in the box with Server 2012.
The Server 2008 way of enabling PING to echo involved netsh.
netsh advfirewall firewall add rule name=”Allow Ping” protocol=icmpv4 dir=in action=allow
Mind you, netsh is still in Server 2012 and this command works, but it is the old way of doing things, lets look forward.
Actually, lets run that netsh command on Server 2012 and see what we get – explore the assumptions of this netsh command.
Get-NetFirewallRule –Name “Allow Ping”
Hmm. No Firewall rules found that match. But in my netsh command I set name=”Allow Ping”, what gives?
Well, if you list all the rules out, you discover that netsh sets the DisplayName property, not the name property of the rule. It creates a random GUID for the Name. And, if you try New-NetFirewallRule you discover that –DisplayName is required but –Name is not. (the things you learn).
Okay, enough discovery.
Let’s create the same rule using PowerShell in Server 2012
New-NetFirewallRule –DisplayName “Allow Ping” –Direction Inbound –Action Allow –Protocol icmpv4 –Enabled True
Now, the really nifty thing is that I can really quickly disable the same rule and turn PING echoes back off.
Set-NetFirewallRule –DisplayName “Allow Ping” –Enabled False
The rule remains, but it is simply disabled so I don’t need to create it again. And I can turn it back on when I need.
And, to remove the rule entirely:
Remove-NetFirewallRule –DisplayName “Allow Ping”