We're trying to capture and record information (e.g., installed software, hotfixes, shares) about all our Windows 2000 servers as part of a disaster recovery plan. Is there a way to automate this task with a script?
There are quite a few available utilities that can capture this type of information. Before you start exploring the available utilities, though, you might want to check with your hardware vendor to see whether it has a recommended solution.
When you're checking out the utilities, you might notice that their developers have differing ideas about what information to capture. For this reason, I created a script, NodeConfigQuery.bat, that runs three free commonly used utilities: the Microsoft Windows 2000 Server Resource Kit's srvinfo.exe, Sysinternals' PsInfo (part of PsTools—http://www.sysinternals.com), and Beyond Logic's Console Computer Information Utility for 2000/XP (compinfo.exe—http://www.beyondlogic.org).
To use NodeConfigQuery.bat, all three utilities must be in the computer's path or must reside in the same directory as the batch file. To launch this script, use the command
where Computer is the name of the machine on which you want to capture information. A sample launch command appears at the beginning of the script, as Listing 1 shows.
NodeConfigQuery.bat runs the utilities and outputs their results to one report file. For easy reference, the report's filename includes the computer's name.
I wrote NodeConfigQuery.bat to run on a local computer. If you want to run the script remotely, you must adapt it. Compinfo doesn't have remote capability, so NodeConfigQuery.bat would need to launch Compinfo with a remote execution tool, such as Sysinternals' PsExec or Beyond Logic's BeyondExec.
An easier way to obtain system information for remote computers is to use the built-in msinfo32.exe tool. To get the tool's command syntax, run the command
"C:\Program Files\Common Files\Microsoft Shared MSInfo\msinfo32.exe" /?
(If you run this command without the /? at the end, the utility's System Information GUI pops up.)
Suppose you want to run Msinfo32 against a remote computer named Server10. You'd use the command
"C:\Program Files\Common Files\Microsoft Shared MSInfo\msinfo32.exe" /report C:\Server10-report /computer Server10
where the /report option specifies the output file's name (i.e., C:\Server10-report) and the /computer option specifies the remote computer's name (i.e., Server10).
The output from Msinfo32 is the text you'd see in the System Information GUI. This text is very verbose. On my test machine, the report took about 2 minutes to run, and the completed report size was about 500KB. However, Msinfo32 returns the command prompt back to the user and generates the report in the background, so the wait might not be a problem for you.
In a disaster recovery situation, you might want to gather other types of data, such detailed share information. The rmtshare.exe tool is an excellent tool to capture share information and permissions data on local or remote computers. Rmtshare hasn't been included in recent resource kits, but Microsoft still offers this tool on its FTP site at ftp://ftp.microsoft.com/bussys/winnt/winnt-public/reskit/nt40/i386/rmtshar.exe.
If you need detailed share information, add Rmtshare to the folder in which you put the other utilities, then add the following command to NodeConfigQuery.bat:
For /f "tokens=1 skip=4" %%i in ('rmtshare \\%node%^|Find /I /V "command"') Do @rmtshare \\%node%\%%i |Find /I /V "command" >>"%outfile%"
The script's report will then include a list of shares and their permissions settings. Note that this command doesn't work correctly if you have spaces in the share's name.