views:

22

answers:

1

So the boss asked for a spreadsheet that would show him all the computers in our enterprise and the users that are currently logged in.

I stopped asking "why?" and started with NBTSTAT. The <03> results were inconsistent. Then I tried NET CONFIG WORKSTATION, and finally PSLOGGEDON.EXE (SYSINTERNALS). These were good, but I'd have to find a way to pass the results of NET VIEW and format the output nicely for a csv.

But then I thought there must be a better way. 90% of our PCs are WinXP so I could use WMIC or maybe DSQuery. I'd rather isolate the command execution to the workstations in our AD Computers container and not touch our Servers.

Does anyone have any recommendations?

A: 

This seems to give me what I want:

FOR /F "skip=3 delims=\ " %%A IN ('net view') DO WMIC /Node:"%%A" ComputerSystem Get UserName /Format:csv 2>nul | MORE /E +2 >> computer_user_list.csv

Maybe someone else could use it.

jonatj