Read Windows Firewall state and rules with netsh
Query whether Defender Firewall is enabled per profile (Domain/Private/Public) and list the rules already in place — without touching the GUI.
01Command
$ netsh advfirewall show allprofiles state02What it does
Before adding an inbound rule you should confirm the profile is even on and whether a rule already exists — duplicates are a common source of confusion. The firewall show rule output includes LocalPort, RemoteAddress, Action, and the Program path, which you can narrow by piping through findstr (e.g. `| findstr /i "8080"`). These commands are read-only; the add/delete siblings modify configuration, so this is a safe exploration starting point.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Netsh - Windows CMDEvidence: SS64 documents the netsh advfirewall contexts: show allprofiles state and firewall show rule name=all for inspecting rules and profile states.
Last verified: 2026-09-17 · Category: Security & Privacy
06Related solutions
Enumerate every wireless network Windows remembers, inspect a profile's settings, and export profiles for backup or transfer to another PC.
Purge cached DNS lookups so Windows re-resolves hostnames from scratch — the fix for 'the new server is live but my browser still hits the old one'.
Understand PowerShell's execution policy scopes and set the one that lets you run your own local scripts without gutting the security model.