Skip to content

Instantly share code, notes, and snippets.

@chadmando
Created March 12, 2020 20:53
Show Gist options
  • Save chadmando/e91ccc9d39bb32b16eb377c0449e719f to your computer and use it in GitHub Desktop.
Save chadmando/e91ccc9d39bb32b16eb377c0449e719f to your computer and use it in GitHub Desktop.
# modified from this blog post https://itluke.online/2018/11/27/how-to-display-firewall-rule-ports-with-powershell/
# Looks for Enabled, Inbound Rules that start with the letter "Q"
Get-netfirewallrule |
Where-Object {$_.Enabled -eq $True -and $_.DisplayName -like "Q*" -and $_.Direction -eq "Inbound"} |
Select-Object -Property Name,
DisplayName,
@{Name='Protocol';Expression={($_ | Get-NetFirewallPortFilter).Protocol}},
@{Name='LocalPort';Expression={($_ | Get-NetFirewallPortFilter).Localport}},
@{Name='RemotePort';Expression={($_ | Get-NetFirewallPortFilter).RemotePort}},
@{Name='RemoteAddress';Expression={($_ | Get-NetFirewallPortFilter).RemoteAddress}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment