How to get the local port ??

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Daniel Krebs Daniel Krebs 2 months, 2 weeks ago.

  • Author
  • #70553
    Profile photo of Del

    I'm trying to get a full report that contains

    DisplayName, Description, Enabled, Profile, Direction, Action, PrimaryStatus, Status + Local Port

    But when I run " Get-NetFirewallPortFilter -Protocol UDP | Get-NetFirewallRule " Doesn't show the local port #

    How to add the local port ?


  • #70555
    Profile photo of Daniel Krebs
    Daniel Krebs

    Hi, the following is a working example:

    Get-NetFirewallPortFilter -Protocol UDP | ForEach-Object {
        $rule = Get-NetFirewallRule -AssociatedNetFirewallPortFilter $PSItem
        [PSCustomObject] @{
            Name = $rule.Name
            DisplayName = $rule.DisplayName
            LocalPort = $PSItem.LocalPort
    } | Sort-Object -Property Name

    – Daniel

You must be logged in to reply to this topic.