Test RDP Connectivity with Powershell

Very simply returns True or False for a given list of hostnames or IP addresses depending on whether or not it can connect to TCP/3389 – a successful connection does not mean that you will be able to login, of course. If you’re running RDP on a non-standard port, you’ll need to adjust the script appropriately.


$results = @()
foreach($name in $computername){
        $result = "" | select Name,RDP
        $result.name = $name
           $socket = New-Object Net.Sockets.TcpClient($name, 3389)
           if($socket -eq $null){
                 $result.RDP = $false
                 $result.RDP = $true
                 $result.RDP = $false
        $results += $result
return $results

4 Replies to “Test RDP Connectivity with Powershell”

    1. I know, I just had a need to test RDP connectivity on a couple of servers at work and knocked something up quickly to do it.

  1. I want to know if it’s possible to test the login in RDP ! Have you an idea ?

    1. I don’t think there’s any easy way to programmatically login interactively over RDP.

Leave a Reply to Hsafla Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.