Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Retrieving firewall rules

$
0
0

Good morning,

 

I'm trying to write a script that will allow me to retrieve the firewall rules an a given machine.  So far, I have tried using the netsh command and the HNetCfg.FwPolicy2 COM object, but they only return firewall rules configured using netsh, the firewall control panel, or a script (see more details here: http://technet.microsoft.com/en-us/library/cc755604(v=ws.10).aspx).

So, with that in mind, I set out to create a script to retrieve the firewall rules directly from the registry - so far, I have the following:

$gpoRules = @(Get-ItemProperty -Path Registry::HKLM\Software\Policies\Microsoft\WindowsFirewall\FirewallRules) 

$localRules = @(Get-ItemProperty -Path Registry::HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules)

 

Where I am encountering trouble is that using Get-ItemProperty will return the list of Propert names with values as a string - not separate entries...

 

Also, once I can get the data separated in to distinct entries, I would like to format the data in to something human readable (i.e. I only need the rule name, action, status (active/inactive), direction, and remote addresses) and have it output as a table.

 


Viewing all articles
Browse latest Browse all 8583

Latest Images

Trending Articles



Latest Images