PowerShell: Get Firewall Rules

Need to check Windows Firewall rules - for security auditing or troubleshooting a blocked connection? This one-liner pulls the active rules straight from the system.

Prerequisites:

  • Privileges: None
  • Module: Built-in, no import needed

Quick Command:

Get-NetFirewallRule -Enabled True | Select-Object DisplayName, Direction, Action -First 10

Example Output:

DisplayName                          Direction Action
-----------                          --------- ------
Network Discovery (SSDP-Out)         Outbound  Allow
Remote Assistance (TCP-Out)          Outbound  Allow
Core Networking - IPv6 (IPv6-In)     Inbound   Allow
File and Printer Sharing (SMB-In)    Inbound   Allow
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.

How It Works:

  • Get-NetFirewallRule returns every firewall rule configured on the system - Windows ships with hundreds of built-in rules by default, most of them disabled, so filtering is essential.
  • -Enabled True filters down to only rules that are actively enforced, skipping the large number of disabled/inactive default rules.
  • DisplayName shows a readable description of what the rule covers, Direction shows whether it applies to Inbound or Outbound traffic, and Action shows whether matching traffic is Allowed or Blocked.
  • -First 10 limits the output, since even the enabled rule set alone is typically dozens of entries.