-
Notifications
You must be signed in to change notification settings - Fork 8.2k
-Repeat/-MtuSize/-Traceroute:$false not respected in Test-Connection #26475
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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, HopAddressTest 2: -MtuSize:$false
PS> $result = Test-Connection -TargetName localhost -MtuSize:$false
PS> $result.GetType().Name
PS> $result | Select-Object MtuSize, Destination, BufferSizeTest 3: -Repeat:$false
PS> # This will run continuously - press Ctrl+C to stop
PS> Test-Connection -TargetName localhost -Repeat:$falseExpected 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 SuccessTest 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 SuccessTest 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 ::1Test 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 9999Test 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.0Visuals
No response