Difference between revisions of "Test Connectivity to Remote Machine Port"
From Notes_Wiki
Line 1: | Line 1: | ||
[[Main Page|Home]] > [[Windows]] | [[Main Page|Home]] > [[Windows]] > [[Network Port and Connectivity Testing in Windows]] > [[Test Connectivity to Remote Machine Port]] | ||
== Test Connectivity to Remote Machine Port == | == Test Connectivity to Remote Machine Port == | ||
Line 30: | Line 30: | ||
[[Main Page|Home]] > [[Windows | [[Main Page|Home]] > [[Windows]] > [[Network Port and Connectivity Testing in Windows]] > [[Test Connectivity to Remote Machine Port]] |
Latest revision as of 06:36, 18 June 2025
Home > Windows > Network Port and Connectivity Testing in Windows > Test Connectivity to Remote Machine Port
Test Connectivity to Remote Machine Port
Use the following PowerShell script to test TCP connectivity to a remote machine’s port:
Script
powershell
$ipaddress = "10.11.21.59" $port = "10005" $connection = New-Object System.Net.Sockets.TcpClient($ipaddress, $port) if ($connection.Connected) { Write-Host "Success" } else { Write-Host "Failed" }
This script attempts to create a TCP connection to the specified IP address and port.
If the connection is successful, it prints Success, otherwise it prints Failed.
Example Output
Success
This output means the connection to IP address 10.11.21.59 on port 10005 was successful.
Home > Windows > Network Port and Connectivity Testing in Windows > Test Connectivity to Remote Machine Port