Need Batch File/Script To Find Multiple Usernames Using Their Machine Names

0

1

I have a list of about 200 machine names. I need to get the UserName of the person on each of those machines.

I can do it individually using the following command. But I'm not looking to do this 200 times and then manually write the results in spreadsheet.

wmic.exe /node:"<MachineName>" ComputerSystem Get UserName

I've been searching for a script that will run through a list of about 200 machine names one by one, and document the result back into a spreadsheet or text document. The format isn't as important as just being able to get that info out of the CMD line and email a document to someone.

ChargerStone

Posted 2018-11-14T15:59:25.797

Reputation: 3

Question was closed 2018-11-20T07:25:25.847

get the UserName of the person on each of those machines... do you mean the username of the currently logged on user? – I say Reinstate Monica – 2018-11-14T17:01:47.427

I'm voting to close this question as off-topic because we are not a script writing service – Canadian Luke – 2018-11-19T21:50:28.587

Answers

0

If you put all the computers in a text file called comps.lst this should work:

for /f %a in (comps.lst) do @wmic.exe /node:"%a" ComputerSystem Get UserName

uSlackr

Posted 2018-11-14T15:59:25.797

Reputation: 8 755

3<MachineName> or %a? – pbies – 2018-11-14T16:15:08.093

1It would work if I could substitute <MachineName> in the script with the text entry (the actual machine name) on each line. – ChargerStone – 2018-11-14T16:24:37.330

Sorry. Fixed to replace with %a – uSlackr – 2018-11-14T18:06:44.363