Thursday, May 23, 2013

Find out where you're logged on

As a sysadmin, I end up logged in all over the place.
Periodically, I'm asked to change my password, and if I'm not logged out from every server, it can cause all sorts of issues.

Update: 2013-11-11
Ignore everything below.  This is so much easier than I was making it.
PsLoggedOn will simply scan your network and tell you where you're logged on. Not sure how I missed this!

PsLoggedon.exe -l MyDomain\MyUser


There is a WMIC command that can be used to see where you're logged in at on the network. This is probably the recommended way if you're running newer servers.
However, we still have a lot of older servers that don't fully support WMIC.  I therefore take the following approach:

From command prompt, run
This populates the list with all DB servers (per our naming conventions).

I then run
This, per our naming conventions, appends the app servers (hosting jboss or WebSphere).
Note the >>, so that the SERVERLIST.txt is not overwritten by the output redirection.

I then execute PSLOGGEDON (download from sysinternals/PSTools) as follows:
for /F %i in (SERVERLIST.txt) do PsLoggedon.exe -L %i >> loggedon_output.txt 2>&1
This will read the systems in SERVERLIST.txt and, for each one, execute the PSLoggedon.exe -L command.  Output will be piped to loggedon_output.txt.
NOTE: loggedon_output.txt is not truncated at any point.  If you're like me and tend to run this from the same place over and over again, you'll need to clean it up manually before you begin.

Good luck :-)

No comments:

Azure Storage, How fast are disks? GRS Plus has a great article on Azure Storage Speed.