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
    Posts
  • #70553
    Profile photo of Del
    Del
    Participant

    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 ?

    Thanks

  • #70555
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    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.