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.

WindowsnetworksecurityfirewallMedium risk
Run `netsh advfirewall show allprofiles state` to check each profile, and `netsh advfirewall firewall show rule name=all` to dump all rules.

01Command

Command
$ netsh advfirewall show allprofiles state

02What 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

RiskMedium risk
RequirementsRead-only commands; listing every rule with `netsh advfirewall firewall show rule name=all` can be very long — filter with `| findstr /i "<name>"`.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Netsh - Windows CMD
    SS64 · technical · 2026-09-17
    Evidence: 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