Skip to content

Get-NetTCPConnection not reporting ports correctly #3277

Open

Description

@ryanhdake

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
  • Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.

Links

https://github.com/MicrosoftDocs/windows-powershell-docs/blob/main/docset/winserver2016-ps/nettcpip/Get-NetTCPConnection.md

Summary

Running Get-NetTCPConnection not reporting all ports correctly. Found 2 machines that report that ports 80 and 443 are only listening on IPv6 when they are in fact listening on IPv4 and IPv6. This was confirmed by bindings in IIS and netstat.

Details

I am using this to test ports on a webserver automatically.
Running netstat -ano | findstr /i ":80 :443" | findstr /i listening | findstr /v "::" reports that the ports are open for IPv4 - this is correct

image

When running get-nettcpconnection | where {$_.localport -eq "80" -or $_.localport -eq "443" -and $_.state -eq "Listen"} reports only the IPv6 ports are open.

image

I have verified these results by running get-nettcpconnection | where {$_.state -eq "listen"} | sort localport
port 135 is reporting for IPv4 and IPv6 but 80 and 443 dont.

image

Suggested Fix

No response

Activity

  1. added
    issue-doc-bugSomething is out of date, unclear, confusing, or broken in the article. Blocks customer success.
    on Mar 14, 2023
  2. officedocspr5 commented on Dec 8, 2023

    @officedocspr5
    Contributor

    To make it easier for you to submit feedback on articles on learn.microsoft.com, we're transitioning our feedback system from GitHub Issues to a new experience.

    As part of the transition, this GitHub Issue will be moved to a private repository. We're moving Issues to another repository so we can continue working on Issues that were open at the time of the transition. When this Issue is moved, you'll no longer be able to access it.

    If you want to provide additional information before this Issue is moved, please update this Issue before December 15th, 2023.

    With the new experience, you no longer need to sign in to GitHub to enter and submit your feedback. Instead, you can choose directly on each article's page whether the article was helpful. Then you can then choose one or more reasons for your feedback and optionally provide additional context before you select Submit.

    Here's what the new experience looks like.

    Note: The new experience is being rolled out across learn.microsoft.com in phases. If you don't see the new experience on an article, please check back later.

    First, select whether the article was helpful:

    Image showing a dialog asking if the article was helpful with yes and no answers.

    Then, choose at least one reason for your feedback and optionally provide additional details about your feedback:

    Article was helpful Article was unhelpful
    Image showing a dialog asking how the article was helpful with several options. Image showing a dialog asking how the article wasn't helpful with several options.

    Finally, select Submit and you're done!

  3. lukedaemon commented on Oct 22, 2026

    @lukedaemon

    Hello,
    This issue can be reproduced on Windows Server 2022 and Windows 11, and I suspect it also affects other recent Windows operating system versions.

    Example

    Port 8200 is only an example; the same happens with other ports.

    netstat -ano | find "8200"

      TCP    0.0.0.0:8200    0.0.0.0:0    LISTENING    6576
      TCP    [::]:8200       [::]:0       LISTENING    6576
    

    Get-NetTCPConnection -LocalPort 8200 returns only:

    LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
    ------------                        --------- -------------                       ---------- -----       --------------
    ::                                  8200      ::                                  0          Listen
    

    Querying the underlying CIM class directly gives the same result, so the gap is in the data source and not in the cmdlet's filtering:

    Get-CimInstance -Namespace root/StandardCimv2 -ClassName MSFT_NetTCPConnection -Filter "LocalPort=8200"

    LocalAddress                        LocalPort RemoteAddress                       RemotePort State       AppliedSetting
    ------------                        --------- -------------                       ---------- -----       --------------
    ::                                  8200      ::                                  0          Listen
    

    The .NET call returns both listeners and agrees with netstat:

    [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties().GetActiveTcpListeners() | Where-Object Port -eq 8200

     AddressFamily Address Port
     ------------- ------- ----
      InterNetwork 0.0.0.0 8200
    InterNetworkV6 ::      8200
    

    This issue was opened on March 14, 2023 and is still active/present.
    Manuela Scanu (@scanum) could it be routed to the team that owns the NetTCPIP module? A cmdlet that silently under-reports listening ports gives a false sense of security in exactly the scenarios it is used for: monitoring and security audits (for example). So it becomes unuseful.

    Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

issue-doc-bugSomething is out of date, unclear, confusing, or broken in the article. Blocks customer success.needs-triageWaiting - Needs triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions