Skip to content

Test-NetConnection bug in PingSucceeded property #25818

@QyhOfficial

Description

@QyhOfficial

Prerequisites

Steps to reproduce

When running Test-NetConnection command with parameter -Port, if TcpTestSucceeded get True, then the ICMP ping will be skipped, and the PingSucceeded property will not be displayed in the console. However, the result object does contain a PingSucceeded property and it's value is always False in this case, you can explicitly check it by$testresult.PingSucceeded. This will cause confusion in some automation testing scenario.

PS C:\Users\Chin> $testresult=test-netconnection -computername 8.8.8.8 -port 53
PS C:\Users\Chin> $testresult

ComputerName     : 8.8.8.8
RemoteAddress    : 8.8.8.8
RemotePort       : 53
InterfaceAlias   : vEthernet (external switch)
SourceAddress    : 192.168.30.162
TcpTestSucceeded : True

PS C:\Users\Chin> $testresult.PingSucceeded
False
PS C:\Users\Chin> test-netconnection -computername 8.8.8.8

ComputerName           : 8.8.8.8
RemoteAddress          : 8.8.8.8
InterfaceAlias         : vEthernet (external switch)
SourceAddress          : 192.168.30.162
PingSucceeded          : True
PingReplyDetails (RTT) : 35 ms

Expected behavior

When TcpTestSucceeded=True, ICMP ping test should not be skipped, and PingSucceeded should be True most of time.

Actual behavior

PS C:\Users\Chin> $testresult.PingSucceeded
False

Environment data

Windows 11, Powershell 7.5.2

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-ExternalThe issue is caused by external component(s).WG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    Status

    Reviewed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions