Contents

Open Ports | Zero Trust

How to check if ports are open to a remote server


PowerShell Code

Use PowerShell to see if ports are open to a remote server.

Living in a zero trust environment can be challenging. Here is some code that I have been using to test for open ports from a Windows server to any type of destination. Just change PortNumber and Destination for your use case.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
$PortNumber = '443'
$Destination = 'Server.vCrocs.info'

$socket = New-Object Net.Sockets.TcpClient
$socket.Connect($Destination,$PortNumber)

if($socket.Connected){
    $PortOpened = 'Port: ' + $PortNumber + ' to ' + $Destination +' is Open! :)'
    $socket.Close()
} # end if
else{
    $PortOpened = 'Port: ' + $PortNumber + ' to ' + $Destination +' IS NOT Open! :('
} # end else

Write-Output  $PortOpened

Linux Commands

If you work with VMware vRealize Suite of appliances here are some commands (curl and Netcat) that can be used with Linux OS to test if ports are open to destination servers.

1
2
curl -v telnet://server01.vCROCS.info:443
nc -ztv server01.vCROCS.info 443 -w 3

  • If you found this Blog article useful and it helped you, Buy me a coffee to start my day.

Article Updated: 2021-04-24