Skip to content

Instantly share code, notes, and snippets.

@drmohundro
Created August 20, 2015 16:42
Show Gist options
  • Save drmohundro/9eba676128f37fbcac32 to your computer and use it in GitHub Desktop.
Save drmohundro/9eba676128f37fbcac32 to your computer and use it in GitHub Desktop.
Determine if a specified server is listening on the default RDP port
# relies on portqry (see http://www.microsoft.com/en-us/download/details.aspx?id=24009)
param (
[Parameter(Mandatory=$true)]
[string]
$server,
[int]
$rdpPort = 3389
)
PortQry.exe -n $server -e $rdpPort
@drmohundro
Copy link
Author

So you've restarted a remote server. Obviously, it kicks you off of RDP. You want to RDP into it once it has rebooted, though. So you keep RDPing but you don't know when it is back yet.

I used to just run ping -t MyServer and wait for it to start responding, but the problem is that the ping response can start before the RDP service begins listening.

Using this, I can know if the RDP service has started listening or not.

It requires the PortQry tool to be in your PATH first.

(side note - I can never remember the name of PortQry either...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment