Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

-Repeat/-MtuSize/-Traceroute:$false not respected in Test-Connection #26475

Copy link
Copy link
@yotsuda

Description

@yotsuda
Issue body actions

Prerequisites

Steps to reproduce

This is a sub-issue of #25242.

The cmdlet Test-Connection does not respect explicit $false values for the -Repeat, -MtuSize, and -Traceroute switch parameters.

Test 1: -Traceroute:$false

PS> $result = Test-Connection -TargetName localhost -Traceroute:$false
PS> $result[0].GetType().Name
PS> $result[0] | Select-Object Hop, Hostname, HopAddress

Test 2: -MtuSize:$false

PS> $result = Test-Connection -TargetName localhost -MtuSize:$false
PS> $result.GetType().Name
PS> $result | Select-Object MtuSize, Destination, BufferSize

Test 3: -Repeat:$false

PS> # This will run continuously - press Ctrl+C to stop
PS> Test-Connection -TargetName localhost -Repeat:$false

Expected behavior

Test 1: -Traceroute:$false

PS> $result = Test-Connection -TargetName localhost -Traceroute:$false
PS> $result[0].GetType().Name
PingStatus
PS> $result[0] | Select-Object Ping, Destination, Status
Ping Destination Status
---- ----------- ------
   1 localhost   Success

Test 2: -MtuSize:$false

PS> $result = Test-Connection -TargetName localhost -MtuSize:$false
PS> $result.GetType().Name
PingStatus
PS> $result | Select-Object Ping, Destination, Status
Ping Destination Status
---- ----------- ------
   1 localhost   Success

Test 3: -Repeat:$false

PS> Test-Connection -TargetName localhost -Repeat:$false
# Should return 4 ping results (default count) and then stop

-Traceroute:$false, -MtuSize:$false, and -Repeat:$false should each behave the same as omitting the respective switch parameter, returning standard ping results.

Actual behavior

Test 1: -Traceroute:$false

PS> $result = Test-Connection -TargetName localhost -Traceroute:$false
PS> $result[0].GetType().Name
TraceStatus
PS> $result[0] | Select-Object Hop, Hostname, HopAddress

Hop Hostname HopAddress
--- -------- ----------
  1 ::1      ::1

Test 2: -MtuSize:$false

PS> $result = Test-Connection -TargetName localhost -MtuSize:$false
PS> $result.GetType().Name
PingMtuStatus
PS> $result | Select-Object MtuSize, Destination, BufferSize

MtuSize Destination BufferSize
------- ----------- ----------
   9999 localhost         9999

Test 3: -Repeat:$false

PS> Test-Connection -TargetName localhost -Repeat:$false
# Runs continuously, ignoring the $false value

-Traceroute:$false performs a traceroute (returns TraceStatus), -MtuSize:$false performs MTU discovery (returns PingMtuStatus), and -Repeat:$false pings continuously, all ignoring the explicit $false value.

Error details

No error is thrown. The cmdlet executes but ignores the explicit $false value for each switch parameter.

Environment data

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.5.4
PSEdition                      Core
GitCommitId                    7.5.4
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.