I'm looking for a way to export existing Windows Firewall rules using PowerShell that includes the path of the Program being referenced (for those rules which reference a program path instead of a port range).
Get-NetFirewallRule
includes a lot of information but seems to be missing Program. Preferably in a human-readable format I can also automate with. Output as PowerShell objects would be best, but something tabular would be good enough.
What I've tried:
- Get-NetFirewallRule, piping to Get-Member, piping to Format-List *
- taking a Get-NetFirewallRule and serializing it with Export-CliXml with a high depth - the program path is not in the XML file.
- brief (brief!) poking around netsh
- I can manually do an export from WF.msc to get a tab delimited list, but I'd like something I can automate.
- I did find this, but it's not human readable and looks like an all/nothing import-export, not something I could use to extract only new rules
This is in the context of managing dozens of build VMs used for continuous integration at a software company, but could also apply to system administration of our other workstations.
So far, I have not found a solution that will let me take rules on one system (specific rules) and create a PowerShell script (or GPO or whatever) to add the same rule to other machines. All I'm missing is program path. Once I have that I can easily handle the rule creation aspect.