Here is the code I finally used.
Function Get-FireWallRule
{
Param ($Name, $Direction, $Enabled, $Protocol, $profile,
$action, $grouping)
$Rules=(New-object –comObject HNetCfg.FwPolicy2).rules
If ($name) {$rules= $rules | where-object {$_.name
–like $name}}
If ($direction) {$rules= $rules | where-object {$_.direction
–eq $direction}}
If ($Enabled) {$rules= $rules | where-object {$_.Enabled
–eq $Enabled}}
If ($protocol) {$rules= $rules | where-object {$_.protocol
-eq $protocol}}
If ($profile) {$rules= $rules | where-object {$_.Profiles
-bAND $profile}}
If ($Action) {$rules= $rules | where-object {$_.Action
-eq $Action}}
If ($Grouping) {$rules= $rules | where-object {$_.Grouping
-Like $Grouping}}
$rules
}
$spaces= " " * 71
Get-firewallRule -enabled $true | sort name | `
format-table -property `
@{label="Name" + $spaces ; expression={$_.name}
; width=75}, `
@{label=”Action” ; expression={$Fwaction[$_.action]}
; width=6 }, `
@{label="Direction" ;
expression={$fwdirection[$_.direction]}; width=9 }, `
@{label=”Protocol” ;
expression={$FwProtocols[$_.protocol]}; width=8 } , `
@{label="Local Ports" ; expression={$_.localPorts}
; width=11}, `
@{label="Application Name" ; expression={$_.applicationname} ;
width=80}
I saved that as listfw.ps1 and then ran:
.\listfw.ps1 | out-string –width 200 | out-file .\fw.txt
I then got what I needed formatted in a way I can use.
Whew.
Thanks
Carl Webster
Consultant and Citrix Technology Professional
http://www.CarlWebster.com<http://www.carlwebster.com/>
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin