3

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.

Tweek
  • 302
  • 3
  • 9
  • I use `ping -a`, which starts beeping if the host is back online (at least on unixoid systems). – Sven Jun 03 '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 03 '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 Answers7

3

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

MDMarra
  • 100,734
  • 32
  • 197
  • 329
1

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.

aleroot
  • 3,180
  • 6
  • 29
  • 37
1

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.

James Ruskin
  • 479
  • 5
  • 14
0

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.

KCotreau
  • 3,381
  • 3
  • 20
  • 24
0

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.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
0

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.

Matt Hamende
  • 129
  • 1
  • 11
-2

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

StackzOfZtuff
  • 1,842
  • 13
  • 21
  • Link-only answers are strongly discouraged. Please provide content *here*, and then link elsewhere for more details. – EEAA Mar 05 '13 at 03:40