Backup Firewall script #8
Replies: 3 comments
-
Thank you for sharing your solution! |
Beta Was this translation helpful? Give feedback.
-
Hello again, I attempted to implement your suggestion but come to conclusion that this method to export firewall is not useful for the following reasons:
$FWPolicy2 = (New-Object -ComObject HNetCfg.FWPolicy2).rules
$FWPolicy2 | where {$_.Direction -eq 0 } It looks like only inbound rules can be retrieved, ex following works: $FWPolicy2 = (New-Object -ComObject HNetCfg.FWPolicy2).rules
$FWPolicy2 | where {$_.Direction -eq 1 } So even if I wanted to write a new export function for control panel firewall it would not work as expected. There are 2 alternatives to your suggestion but with drawbacks:
I could be wrong on some points, if so let me know. Following reference was helpful: |
Beta Was this translation helpful? Give feedback.
-
Hello again @kidguardian I don't know if you're still watching this discusion but, These functions instead of using slow filters, drill and parse registry which as fast as it can be. Thank you again for reporting! |
Beta Was this translation helpful? Give feedback.
-
I just came across your WindowsFirewallRuleset after I recently created a backup script using the get-netfirewallrule commands and exporting to CSV but was completely taken aghast at the amount of time (1 minute to 20+ minutes) it took to export the entire rule set verses the under 1 second pull and export to CSV using the older object model. Example:
$fwRules=(New-object -ComObject HNetCfg.FWPolicy2).rules
It is also much faster to use this method to search for existing open ports, etc. Not sure if you knew about the older method and if it still gives you what you want but I thought I would mention it.
Beta Was this translation helpful? Give feedback.
All reactions