Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
January 19, 2005
Using the net view command and Psloggedon freeware, I have scripted ComputerUserCSV.bat to create a .CSV file of computer names and logged on user names in a domain.
The syntax for using ComputerUserCSV.bat is:
ComputerUserCSV FileName
Where FileName is the name of the file that will contain "NetBIOS computer name","user SAMID", like:
"JSI007","Jennifer""JSI009","Jerry"
ComputerUserCSV.bat contains:
@echo offif {%1}=={} @echo Syntax: ComputerUserCSV FileName&goto :EOFsetlocal ENABLEDELAYEDEXPANSIONset file=%1if exist %file% del /q %file%set fnd1=Find /i "%USERDOMAIN%"set fnd2=Find /i /v "Error:"set fnd3=Find /i /v "Unknown"set fnd4=Find "\"for /f "Tokens=1" %%c in ('net view /domain:%USERDOMAIN%^|%fnd4%') do ( set computer=%%c for /f "Tokens=*" %%u in ('psloggedon -l -x !computer!^|%fnd1%^|%fnd2%^|%fnd3%') do ( set user=%%u call set user=!user:%USERDOMAIN%=! @echo "!computer:~2!","!user!">>%file% ))endlocal
You May Also Like