Test-NetConnection -Computer $Server -CommonTCPPort RDP
Using the Test-NetConnection cmdlet you can confirm that a server is reachable via the standard RDP port of 3389.
PS C:\> $Server = 'AD01' >> Test-NetConnection -Computer $Server -CommonTCPPort RDP ComputerName : DC01 RemoteAddress : 10.10.5.12 RemotePort : 3389 InterfaceAlias : vEthernet (External (NIC)) SourceAddress : 10.10.5.200 TcpTestSucceeded : True