How To Test Port Connectivity Between Different Machines WITHOUT Telnet
Автор: Kyle Louden
Загружено: 2018-02-27
Просмотров: 4786
Описание:
Set-ExecutionPolicy: https://docs.microsoft.com/en-us/powe...
####################################
The following checks port connection only
Save the following as a .ps1 file and run as shown in video:
$server = Read-Host -Prompt 'Input your server name '
$port = Read-Host -Prompt 'Input the port being tested '
Write-Host "::::::::::::::::::::::::::::::::::::::::"
$server = Read-Host -Prompt 'Input your server name '
$port = Read-Host -Prompt 'Input the port being tested '
Write-Host "::::::::::::::::::::::::::::::::::::::::"
try
{
Write-Host "Testing connection to port $port on $server" -ForegroundColor Yellow
$tcp=new-object System.Net.Sockets.TcpClient
$tcp.connect("$server", $port)
Write-Host "Connection to $server on port $port succeeded!" -ForegroundColor Green
$tcp.close()
Write-Host "::::::::::::::::::::::::::::::::::::::::"
}
catch
{
Write-Host "Connection to $server on port $port failed!" -ForegroundColor Red
Write-Host "Not able to communicate over port $port." -ForegroundColor Red
Write-Host "::::::::::::::::::::::::::::::::::::::::"
}
####################################
The following checks DNS resolution, ICMP ping, and port connectivity.
Save the following as a .ps1 file and run as shown in video:
Write-Host "::::::::::::::::::::::::::::::::::::::::"
$server = Read-Host -Prompt 'Input your server name '
$port = Read-Host -Prompt 'Input the port being tested '
Write-Host "::::::::::::::::::::::::::::::::::::::::"
try
{
Write-Host "Testing DNS resolution for $server" -ForegroundColor Yellow
nslookup $server
Write-Host "::::::::::::::::::::::::::::::::::::::::"
Write-Host "Testing ICMP ping for server $server" -ForegroundColor Yellow
ping $server
Write-Host "::::::::::::::::::::::::::::::::::::::::"
Write-Host "Testing connection to port $port on $server" -ForegroundColor Yellow
$tcp=new-object System.Net.Sockets.TcpClient
$tcp.connect("$server", $port)
Write-Host "Connection to $server on port $port succeeded!" -ForegroundColor Green
$tcp.close()
Write-Host "::::::::::::::::::::::::::::::::::::::::"
}
catch
{
Write-Host "Connection to $server on port $port failed!" -ForegroundColor Red
Write-Host "Not able to communicate over port $port." -ForegroundColor Red
Write-Host "::::::::::::::::::::::::::::::::::::::::"
}
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: