Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
I use ping -a, which starts beeping if the host is back online (at least on unixoid systems). –  Sven Jun 3 '11 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 Jun 3 '11 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 Jun 17 '11 at 18:25

7 Answers 7

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

share|improve this answer
    
simple, yet effective –  Nixphoe Jun 3 '11 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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

you could create a script that loops

QWINSTA /SERVER:myserver "RDP-TCP"

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.

share|improve this answer
    
Bah, Access Denied, though that probably has to do with the server not being in the domain... –  Vincent Vancalbergh Aug 19 '13 at 11:33

Quick and dirty Powershell script that I use daily:

<#
.Synopsis
Checks for and connects to RDP on a given server.
.Description
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.
.Example
rdpupyet.ps1 ITG-SRV-INF01 -Verbose
#>
[CmdletBinding()]
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.

share|improve this answer
1  
Reading it over, I'm embarrassed at how long it's been since I've revised this. Rewrite time! –  James Ruskin Jun 9 at 10:55

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

share|improve this answer
    
Link-only answers are strongly discouraged. Please provide content here, and then link elsewhere for more details. –  EEAA Mar 5 '13 at 3:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.