I often find myself connecting to a workstation or server with Remote Desktop to perform a task which requires a reboot. In these cases, I usually need to reconnect after the host comes back online to ensure everything went as planned or to continue my work. In these cases, I will typically launch "ping -t" in a command prompt to let me know when I can reconnect.

However, I will occasionally get distracted with something else while waiting for the host to come back online and forget to come back to it. It would be really nice to be alerted when the host is back online and allow me to reconnect (ideally with a single click).

Does anyone know of an easy way to accomplish this? I'm thinking there must be a free utility available, or perhaps it could be done with a PowerShell script.

  • I use ping -a, which starts beeping if the host is back online (at least on unixoid systems).
    – Sven
    Commented Jun 3, 2011 at 21:56
  • Personally I'm far too paranoid to reboot a host without some level of access to the console. Whether its via ILO, or vCentre if its a virtual host. That way you can see if something stops it from shutting down or coming back up, which you can't always see from an RDP session. It also means you can see when its back online. Do your host support anymof these features?
    – Matt
    Commented Jun 3, 2011 at 22:48
  • @SvenW: Unfortunately, that doesn't appear to be a feature of the ping command on Windows. @Matt: It's really the remote admin of workstations that is the main use case here. I can always phone a user and ask them to reboot their PC, or walk over to their office if need be.
    – Tweek
    Commented Jun 17, 2011 at 18:25

7 Answers 7


Quick and dirty Powershell script that I use daily:

Checks for and connects to RDP on a given server.
This script tests for an open port 3389 (standard Windows RDP), and if it finds it, passes the IP to mstsc.exe. Otherwise it retries indefinitely. Ctrl+C will halt the script.
.Parameter ip
IP or FQDN of a Windows machine to test. Only takes one argument.
.Parameter wait
Will assume that the machine is still up, wait until it stops responding (even once), and then try to connect. Good for machines that are about to reboot.
.Parameter Verbose
Will print a line each time it tries unsuccessfully.
rdpupyet.ps1 ITG-SRV-INF01 -Verbose
param($ip, [switch]$wait)

function Get-DownYet ($ip) {
    Write-Verbose "Waiting for $IP to shut down."
    do {
        try {$up = New-Object System.Net.Sockets.TCPClient -ArgumentList $ip,3389}
        catch {$up = $false}
    until ($up -eq $false)
    Write-Verbose "$IP no longer responding."

Write-Verbose "Testing RDP Connection... Ctrl+C to quit."

if ($wait) {Get-DownYet $ip}
do {
    try {$success = New-Object System.Net.Sockets.TCPClient -ArgumentList $ip,3389}
    catch {Write-Verbose "RDP not active. Retrying."}
while (!$success)

mstsc.exe /v:$ip /admin

Doesn't time out, I'm afraid. But that could be easily added, along with a quick beep on successful response.
The bit I'm more happy with (taken from a currently unremembered source on the internet) is that this won't try and connect when the server comes responds to ping - instead, only when the standard RDP port is accessible.

  • 2
    Reading it over, I'm embarrassed at how long it's been since I've revised this. Rewrite time! Commented Jun 9, 2015 at 10:55

Write "don't forget about $ServerName" on a sticky note and put it on your monitor.

  • simple, yet effective
    – Nixphoe
    Commented Jun 3, 2011 at 23:38

Look at this function that start an RDP Session and at this piece of script for PowerShell .

Look at this piece of script code :

#This piece waits for the Server to come back online . do{$result = $ping.send("ServerName");write-host "." -NoNewLine -ForegroundColor "Red"} until ($result.status -eq "Success")

you could easily add the start RDP call after the loop that wait the host to come back on line . It could be not so difficult to achieve what you want with this two script.


OK, I don't know of anything that will call your cell phone, but if you open a command box, and do "ping -t" minus the quotes, it will keep pinging...not just the 4 times. It is hard to ignore that in the middle of your screen when you get back.

In the alternative, I strongly suggest you use choline daily as your mind is frying at a relatively young age.


I have a simple script on each of my servers that emails me when the server has rebooted. It's a batch file using blat on Windows, perl scripts on Mac and Linux. They are triggered by whatever means is appropriate to the OS. e.g. a Machine startup script on Window.


you could create a script that loops


this is a quick way to see what users are connected to a server, this particular syntax would looks specifically for the RDP listen session on that server, once that visible it should be possible to logon, i use the command slightly differently in a script that actually crawls around 60 servers, and identifies where on the network a user is logged in.

  • Bah, Access Denied, though that probably has to do with the server not being in the domain... Commented Aug 19, 2013 at 11:33

There are a couple of scripts available for this now, see:

  • Link-only answers are strongly discouraged. Please provide content here, and then link elsewhere for more details.
    – EEAA
    Commented Mar 5, 2013 at 3:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .