Friday, May 24, 2013

Get Windows Firewall rule status in Windows 8 and Server 2012



We can use the Get-NetFirewallRule cmdlet to achieve this. First, let us see how we can use this cmdlet on the local system.
1
Get-NetFirewallRule -All
The above command will list all available Firewall rules irrespective of their state (enabled or disabled) or action (allowed or denied). To filter this further to only enabled firewall rules, we can run:
1
Get-NetFirewallRule -Enabled True
We can filter this further and retrieve only the rules that are enabled and are set to allow.
1
Get-NetFirewallRule -Enabled True -Action Allow
So, how do we use this to retrieve the rules from a remote system? Simple, we need to use a computer name string or a CIM session object as an argument to the -CimSession parameter of Get-NetFirewallRule cmdlet.
1
2
$cimSession = New-CimSession -ComputerName Server-03
Get-NetFirewallRule -CimSession $cimSession -Enabled True -Action Allow
Or
1
Get-NetFirewallRule -CimSession Server-03 -Enabled True -Action Allow

No comments:

Post a Comment