0

I'm trying to make a batch file to run the systeminfo command.

I am using this command for one server and it's working but I need for multiple servers.

SYSTEMINFO /S ServerName /U My_Domain\my_domain_account /p my_password >C:\Systeminfo.txt

I couldn't use powershell, we have windows server 2003, 2008 and 2008R2.

I need to check Registered Owner and Registered Organization but would be great to have output like above command.

Thank You in Advance

rozbeh85
  • 37
  • 2
  • 3
  • 7

1 Answers1

1

Put your list of servers in a text file, one server name per line. Then create a .cmd file that looks like this:

@echo off
setlocal enableextensions
for /f %%s in ('type "serverlist.txt"') do call :PROCESS %%s
goto :END

:PROCESS
systeminfo /s %1 > %1.txt
goto :EOF

:END
endlocal

When you run this script you will have .txt files with system info for each server.

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62
  • I should put domain and domain account on batch file. Also could I use csv and put all servers in one csv file? – rozbeh85 Jun 23 '14 at 18:46
  • The shell script (.cmd batch file) solution does not use a CSV file. The above code assumes a file called serverlist.txt that contains a list of server name, one server name per line. – Bill_Stewart Jun 23 '14 at 18:54
  • @echo off setlocal enableextensions for /f %%s in ('type "servers.txt"') do call :PROCESS %%s goto :END :PROCESS SYSTEMINFO /S %1 /U domain\account /P password /FO CSV > C:\systeminfo.csv goto :EOF :END endlocal I changed your script, the output is last server name. so it should check one server, save it and then go to the next one, all of them in one output. – rozbeh85 Jun 23 '14 at 18:55
  • If you write `> C:\systeminfo.csv`, the CSV file will contain information for only the last server in the list. You could write `>> C:\systeminfo.csv`, but then you will have to edit the CSV file afterwards to remove all of the duplicated header lines. – Bill_Stewart Jun 23 '14 at 18:58
  • Instead I would recommend `/CSV /NH >> C:\systeminfo.csv` to omit the header lines. – Bill_Stewart Jun 23 '14 at 19:09