Sunday, March 1, 2009

Script to get information about “USERS” from remote computer / server

This small scripts allows to get information from remote computer / server. All data will be saved in XML format. Create a .bat file and put into in the following context:

@Echo off

Rem .
Rem . http://thesystemadministrator.com - http://www.admininfo.ca
Rem .

@Echo Please wait….

SET STOREPATH=C:\TMP
SET RCOMP= “Put here IP or Name of remote computer / server”

set DM=ADMININFO
set USR=ADM
set PASS=PASSWORD

NET USE \\%RCOMP%\ipc$ /user:%DM%\%USR% %PASS% > NUL 2>&1

REM ………. Checking OS Version ……….
For /F “Tokens=1,2,3* Delims= ” %%a in (’@REG QUERY “\\%RCOMP%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion” /v ProductName^| find /i “ProductName”‘) Do SET OSVER=%%d
IF “%OSVER%” == “Windows 2000″ @Echo %OSVER% &goto :EOF

@echo ^ > %STOREPATH%\%RCOMP%_CompInfo.xml
@echo ^^en^ >> %STOREPATH%\%RCOMP%_CompInfo.xml
@echo ^Report of %RCOMP%^ >> %STOREPATH%\%RCOMP%_CompInfo.xml

REM ………. Users ……….
@echo ^^Users^ >> %STOREPATH%\%RCOMP%_CompInfo.xml
For /F “Tokens=1,2 Delims==” %%a in (’”@WMIC /node:%RCOMP% /user:”%DM%\%USR%” /password:%PASS% USERACCOUNT get NAME /value | find /i “NAME””‘) Do @echo ^^%%a^^%%b^^ >> %STOREPATH%\%RCOMP%_CompInfo.xml
@echo ^
>> %STOREPATH%\%RCOMP%_CompInfo.xml
REM ………. Users ……….

@echo ^
>> %STOREPATH%\%RCOMP%_CompInfo.xml

Note: Remember to set IP or Name of remote computer / server

That it!

-