I regularly administer Windows 2000 Server and Windows Server 2003 machine using Terminal Services. In W2K I use Terminal Services in Administration mode and in W2K3 I use Remote Desktop. Basically this is the same thing but it's packaged a bit differently on the two OSes. In both situations there are only 2 users allowed for administration so occasionally both are used up and I can't access the server. This may happen if two people are legitimately using the servers or if someone forgot to log off. Yes, I do have the settings set to automatically disconnect and/or log off a user after X minutes of inactivity but even with that there are times when I need to be able to manage this remotely.
You would think this would be as easy as connecting to the remote server by adding the Terminal Services Manager snap-in to a MMC console or remotely stopping and starting the service (in a pinch). Strangely, these obvious solutions aren't available. Terminal Services Manager doesn't exist as a snap-in to connect to a remote machine and because the TermService service is a core system service, you can't even stop it on the local machine, let alone a remote one.
Fortunately there is an easy solution. Windows 2000+ (includes Windows XP and 2003) have two command-line tools called qwinsta and rwinsta that can query and reset a remote session.
For example, let's say that I can't gain access to a server using Terminal Services because both sessions are used up. I can use another server to check the status of the first one. As long as the logged in user has administrative rights on the non-accessible machine I would run this:
Where 126.96.36.199 is the IP address or name of the non-accessible machine.
This will display something like this:
> qwinsta /server:188.8.131.52
SESSIONNAME USERNAME ID STATE TYPE DEVICE
console 0 Conn wdcon
rdp-tcp 65536 Listen rdpwd
rdp-tcp#470 Bob 1 Active rdpwd
rdp-tcp#471 Jane 3 Active rdpwd
Now I know that Bob and Jane are the two that are logged in. Since Jane left the office 20 minutes ago I know that she forgot to log off. I don't know where Bob is but I only need one session so I'll ignore him for now.
To disconnect Jane's session I would type this:
rwinsta /server:184.108.40.206 3
Notice the 3 which is the session ID I found from using qwinsta above.
Yet another option with W2K3 is a new feature that lets you connect to the desktop directly and gain a 3rd session.
If you're like me, you probably noticed that rwinsta and qwinsta seems like strange names. This came from the Citrix Metaframe days which Terminal Services has descended from. It stands for:
qwinsta = Query WINdows STAtion
rwinsta = Reset WINdows STAtion
One final comment. Microsoft has replaced these two tools with Query but since qwinsta and rwinsta is fully compatible with W2K WinXP and W2K3 I choose to use it instead.
Note: In Windows Server 2003, you can right-click on the root in Terminal Services Manager and Connect to another server. Also, if you are in an Active Directory domain and using Windows 2000 Server, you can Connect to All Servers and access remote servers from the GUI. But, in a Windows 2000 Server not connected to a domain, you run into the limitations that prompted this blog.
Finally, the time has come for me to start my own blog. My first comment is how impressed I am with this .Text interface that Scott Watermasysk has put together. Hats off to Scott W.
As my first post, I figure I should probably mention a bit about myself so anyone reading this has a bit of a perspective of where I'm coming from. First off, I'm not a writer by any stretch of the imagination. I always battle with any type of writing but I guess I can't hide from it forever.
The other thing I'm not is an expert developer. I pale in comparison to many of the other developers blogging here and elsewhere (or not blogging for that matter). Most of my expertise is with IIS, ASP.NET and server administration. That's not to say that I don't get my feet wet with programming on a fairly regular basis and actually I've been working with web development for a number of years. Between 1997 and now I've worked to some degree with Perl, PHP, Cold Fusion and starting in 2000 I've worked primarily with Classic ASP and ASP.NET. I get to spend a comfortable amount of time with ADSI/WMI and WSH and other cool things like that so I'm sure I'll write about a mixture of things that will hopefully be useful to some people.
All in all, I expect most of my posts will be things regarding the administrative side of ASP.NET, IIS, web technologies and even computer technologies in general. Occasionally I might surprise myself and have something to say on the development end of things but don't expect that to be the norm.
Since I'm writing my first blog on Christmas Eve Day, I wish a Merry Christmas to all!