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!
http://technet.microsoft.com/en-us/sysinternals/bb897545

Example:
PsLoggedon.exe -l MyDomain\MyUser

*facepalm*
___

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.
L
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
NET VIEW | FIND /I "DB" > SERVERLIST.txt
This populates the list with all DB servers (per our naming conventions).

I then run
NET VIEW | FIND /I "AS" >> SERVERLIST.txt
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:

DBT-50000 when using DBCA.bat on Windows (Oracle 19.11)

I’ve been having some trouble getting DBCA to run in order to create databases. Thought I’d share it with you, and thus document it for la...