Difference between revisions of "Test-NetConnection Cmdlet Reference and Usage"

From Notes_Wiki
(Created page with "Home > Windows > Windows OS Notes > Test-NetConnection PowerShell Cmdlet Reference '''Description''' ---------------------- The '''Test-NetConnection''' cmdlet is used to display diagnostic information for network connectivity. It supports: * Ping test * TCP port test * Traceroute * Route and source address diagnostics Module * NetTCPIP '''Test-NetConnection: Syntax and Parameter Reference''' -------------------------------------------...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[Main Page|Home]] > [[Windows]] > [[Windows OS Notes]] > [[Test-NetConnection PowerShell Cmdlet Reference]]
[[Main Page|Home]] > [[Windows]] > [[Network Port and Connectivity Testing in Windows]] > [[Test-NetConnection Cmdlet Reference and Usage]]
 




Line 107: Line 106:




[[Main Page|Home]] > [[Windows]] > [[Windows OS Notes]] > [[Test-NetConnection PowerShell Cmdlet Reference]]
[[Main Page|Home]] > [[Windows]] > [[Network Port and Connectivity Testing in Windows]] > [[Test-NetConnection Cmdlet Reference and Usage]]

Latest revision as of 06:36, 18 June 2025

Home > Windows > Network Port and Connectivity Testing in Windows > Test-NetConnection Cmdlet Reference and Usage


Description


The Test-NetConnection cmdlet is used to display diagnostic information for network connectivity. It supports:

  • Ping test
  • TCP port test
  • Traceroute
  • Route and source address diagnostics


Module

  • NetTCPIP


Test-NetConnection: Syntax and Parameter Reference


powershell

Test-NetConnection [[-ComputerName] <String>] [-TraceRoute] [-Hops <Int32>] [-InformationLevel <String>]
Test-NetConnection [[-ComputerName] <String>] [-CommonTCPPort] <String> [-InformationLevel <String>]
Test-NetConnection [[-ComputerName] <String>] -Port <Int32> [-InformationLevel <String>]
Test-NetConnection [[-ComputerName] <String>] [-DiagnoseRouting] [-ConstrainSourceAddress <String>] [-ConstrainInterface <UInt32>] [-InformationLevel <String>]
                                                     
  • -ComputerName - DNS name or IP address of the target.Alias:RemoteAddress, cn
  • -Port - TCP port to test (e.g., 80 for HTTP). Alias: RemotePort
  • -CommonTCPPort - Predefined service ports (HTTP, RDP, SMB, WINRM)
  • -TraceRoute - Performs a traceroute to the destination
  • -DiagnoseRouting - Enables route diagnostics
  • -ConstrainInterface - Forces diagnostics through a specific interface index
  • -ConstrainSourceAddress - Forces diagnostics from a specific source IP address
  • -Hops - Sets the number of hops for traceroute
  • -InformationLevel - Level of output: Detailed or Quiet


Outputs

  • NetRouteDiagnostics — Returned for route diagnostic tests
  • NetConnectionResults — Returned for ping or port connection tests


Examples


Example 1: Test ping to default internet beacon

powershell

Test-NetConnection


Example 2: Ping with detailed output

powershell

Test-NetConnection -InformationLevel "Detailed"


Example 3:Test TCP port (HTTP - Port 80)

powershell

Test-NetConnection -Port 80 -InformationLevel "Detailed"


Example 4: Ping a specific remote host

powershell

Test-NetConnection -ComputerName "www.contoso.com" -InformationLevel "Detailed"


Example 5: Route diagnostics for a remote host

powershell

Test-NetConnection -ComputerName www.contoso.com -DiagnoseRouting -InformationLevel Detailed


Example 6: Route diagnostics with constrained interface

powershell

Test-NetConnection -ComputerName "www.contoso.com" -ConstrainInterface 5 -DiagnoseRouting -InformationLevel "Detailed"




Home > Windows > Network Port and Connectivity Testing in Windows > Test-NetConnection Cmdlet Reference and Usage