Question

Locked

determine what user is logged in remotely (command line)

By knowledgebased ·
Windows XP:
I'd like to perform an audit on the office by pinging an IP address (known) and resolving it to a hostname (unknown). I am using ping -a xxx.xxx.xxx.xxx

Is there another command or parameter I can use that will tell me what user is logged in to a particular hostname/IP address?

I have a feeling the %username% variable might be involved.

Any ideas?

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Why WMIC is cool

by scott_heath In reply to determine what user is lo ...

Try "WMIC /NODE:<COMPUTERNAME> COMPUTERSYSTEM GET USERNAME" and see how that works out.

If you will be doing this on multiple systems I suggest using either PowerShell or VBScript (or even .NET if you like) and make a script that pulls all computernames from Active Directory and uses WMI to contact each computer and get the username.

Regards,
Scott

http://scottisageek.spaces.live.com

Collapse -

the solutions I'm looking for

by knowledgebased In reply to Why WMIC is cool

thanks for those suggestions. I'm looking for a more automated approach. I'll have to look into those things.

Collapse -

Automated

by Bizzo In reply to the solutions I'm looking ...

Create a file called IP.txt which has a list of the IP addresses you want to look at, then create a batch file with the following:

for /f %%a in (IP.txt) do WMIC /NODE:%%a computersystem GET name, username

It will go through each of the IP addresses in the file and return the name of the machine and the user currently logged in.

Collapse -

Re: Automated

by mikesmobile In reply to Automated

Worked great. Good advice!

Collapse -

Automation

by scott_heath In reply to the solutions I'm looking ...

Command line automation is possible, but has clunky error trapping and such.

That's why I recommend using VBScript for automation. You can pull the list of computers from your domain using ADO and use WMI to ping before attempting to connect and then use WMI to retrieve the logged on user name (as well as other useful stuff) and write it all to a log file.

If you need help I can give you a basic example. Or you can go to my blog, look at my SkyDrive for my Server Inventory script. It's overkill for what you are needing but it covers the basics. if you don't have a SMS platform you could use the Server Invintory for PCs, it just needs a tweak or two.

Regards,
Scott

http://scottisageek.spaces.live.com

Collapse -

WMIC -- Nice!!

by Churdoo In reply to Why WMIC is cool

I believe Scott's suggestion will do exactly what you're asking for. For example, the command:

WMIC /NODE: xxx.xxx.xxx.xxx COMPUTERSYSTEM GET USERNAME
Will return the username currently logged into xxx.xxx.xxx.xxx

or
WMIC /NODE: "workstation_name" COMPUTERSYSTEM GET USERNAME
will return the username currently logged into "workstation_name"

Collapse -

oh thats cool

by Slayer_ In reply to WMIC -- Nice!!

Gotta remember this :)

Collapse -

GOLDEN!!!

by Kelly2121 In reply to WMIC -- Nice!!

Thanks for this extremely useful tip!!! never knew about wmic.

Back to Software Forum
9 total posts (Page 1 of 1)  

Related Discussions

Software Forums