Export and restore Windows Firewall rules (netsh advfirewall)
Snapshot every firewall rule, profile and setting into a single .wfw file with netsh advfirewall export, and put it all back with import.
Run netsh advfirewall export "C:\backup\firewall-policy.wfw" to back up the full firewall policy, and netsh advfirewall import to restore it.
01Command
Command
$ netsh advfirewall export "C:\backup\firewall-policy.wfw"02What it does
The .wfw file captures inbound and outbound rules plus per-profile state (on/off, default actions), which is far more complete than a PowerShell Get-NetFirewallRule dump and quicker than rebuilding by hand. Import replaces the current policy wholesale, so it doubles as an instant rollback after a bad batch of rule changes. Pair it with netsh advfirewall reset to restore factory defaults when a machine has accumulated years of cruft.
03Risk
!Warning: Import overwrites the entire firewall policy — rules created after the export are gone, so export again right before any restore experiment.
04Undo
Undo
$ netsh advfirewall import "C:\backup\firewall-policy.wfw"05Sources
- NETSH - Windows CMDEvidence: SS64 documents the netsh advfirewall context, including export and import of the complete firewall policy to and from a .wfw file.
Last verified: 2026-09-17 · Category: Security & Privacy