How to get the local port ??

Welcome Forums General PowerShell Q&A How to get the local port ??

This topic contains 1 reply, has 2 voices, and was last updated by

 
Moderator
1 year, 6 months ago.

  • Author
    Posts
  • #70553
    Del

    Participant
    Points: 0
    Rank: Member

    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

    Moderator
    Points: 24
    Team Member
    Rank: Member

    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

The topic ‘How to get the local port ??’ is closed to new replies.