Windows Firewall
Exporting Windows Firewall
Using WFW
To export all Windows Firewall rules:
Open the MMC "Windows Defender Firewall with Advanced Security" (Win + R > "wf.msc").
In the tree, right-click the first item (Windows Defender Firewall with Advanced Security on Local Computer) > Export Policy
Save the policy as a "wfw" file.
Using Registry
Alternatively, export the following registry entry:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules
Using MMC
MMC can export any table shown as CSV.
Open the MMC "Windows Defender Firewall with Advanced Security" (Win + R > "wf.msc").
In the tree, right-click "Inbound Rules" > Export List > save the file as "Text (Tab Delimited)".
In the tree, right-click "Outbound Rules" > Export List > save the file as "Text (Tab Delimited)".
NOTE: Because the export doesn't delimit ",", it's best not to choose "CSV" for the export. However if you have the CSV then you can find-replace ", " with "; " to quickly fix the issue.
Using Powershell
Powershell can be well, powerful, but with power comes great responsibility (and way too much information):
Import-Module -Name 'NetSecurity'
Get-NetFirewallRule | Export-Csv -Path .\firewall.csv -Delimiter ';'Â
Using Netsh
While it is easy to create new rules in netsh, it is not possible to list all the firewall rules in netsh. You can only import and export .wfw files. This means you're better off usually using the MMC GUI to import and export.