Test-NetConnection - more output following Get-Date

Hi folks. I tried to do some searches on this but couldn’t find much. I wanted to use Test-NetConnection to check when servers were back up after patching, and threw in a “Get-Date” in front to track when I last ran things. It seems whether using ISE, PS Code, or if I string 2 commands with a semi-colon I get a lot more lines from Test-NetConnection if Get-Date runs before it. Any thoughts as to why this happens? I did figure out I can pipe get-date to Out-Host and the usual 6 lines of output are shown. I just want some help understanding why “Get-Date” causes the next cmdlet to behave differently. Thanks!

This is using PowerShell 5.1 on Windows 10 in case that matters.

Note - The URL below has been replaced with “googlecom” to get around the new user post 2 link limit.

Example 1 - test-netconnection
PS C:> test-netconnection -computername googlecom -port 443

ComputerName : google.com
RemoteAddress : 142.250.190.110
RemotePort : 443
InterfaceAlias : Ethernet
SourceAddress : 10.5.8.56
TcpTestSucceeded : True

Example 2 - get date and test-netconnection
PS C:> get-date
test-netconnection -computername googlecom -port 443

Thursday, January 12, 2023 2:53:59 PM

ComputerName : googlecom
RemoteAddress : 142.250.190.110
ResolvedAddresses : {142.250.190.110}
PingSucceeded : False
PingReplyDetails :
TcpClientSocket :
TcpTestSucceeded : True
RemotePort : 443
TraceRoute :
Detailed : False
InterfaceAlias : Ethernet
InterfaceIndex : 7
InterfaceDescription : Intel(R) Ethernet Connection (6) I219-LM
NetAdapter : MSFT_NetAdapter (CreationClassName = “MSFT_NetAdapter”, DeviceID = “{285E789E-C32F-44B6-9066-94EB72CC3F88}”, SystemCreationClassName = “CIM_NetworkPort”,
SystemName = “My_Worktstation1”)
NetRoute : MSFT_NetRoute (InstanceID = “:8:8:8:9:55A55;:8?8B8???55;”)
SourceAddress : 10.5.8.56
NameResolutionSucceeded : True
BasicNameResolution : {Microsoft.DnsClient.Commands.DnsRecord_AAAA, Microsoft.DnsClient.Commands.DnsRecord_A}
LLMNRNetbiosRecords : {}
DNSOnlyRecords : {Microsoft.DnsClient.Commands.DnsRecord_AAAA, Microsoft.DnsClient.Commands.DnsRecord_A}
AllNameResolutionResults : {Microsoft.DnsClient.Commands.DnsRecord_A, Microsoft.DnsClient.Commands.DnsRecord_AAAA}
IsAdmin : False
NetworkIsolationContext : Internet
MatchingIPsecRules :

The Get-Date is messing with the standard default parameters written to the host. Just pipe to Select * to show all properties in the console.

test-netconnection -computername googlecom -port 443 | Select *

Here is some addtl info if you would like to understand:
Hiding Properties in Return Results | IderaBlog

Thanks rob-simmers. I had a vague idea and your details gave me what I needed!. I searched a bit more on this and wanted to share with the community. This link was helpful - Using PropertySets - powershell.one
To get what I wanted, which is to run Get-Date and then Test-Netconnection (with default output) piping to “Out-Default” un-does the “messing with the standard default parameters” from using Get-Date.

Sample that shows extra output:
Get-Date; Test-NetConnection localhost

Sample that results in default output:
Get-Date; Test-NetConnection localhost | Out-Default

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.