Test Connectivity to Remote Machine Port
From Notes_Wiki
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