Listing 1: LogDump.cmd @Echo Off setlocal BEGIN COMMENT LINE :: Specify the list of servers, separated by spaces, to run this script against. END COMMENT LINE set serverlist=pdc bdc BEGIN COMMENT LINE :: Generate the date extensions for the output filename and the .zip archive. END COMMENT LINE :: BEGIN CALLOUT A for /f "Tokens=1,2,3 delims=/" %%i in ('date /t') do set filedate=%%i_%%j_%%k & set zipdate=%%i_%%k set filedate=%filedate:~4,10% set zipdate=%zipdate:~4,7% :: END CALLOUT A BEGIN COMMENT LINE :: For each of the servers specified in serverlist, run Dumplog. END COMMENT LINE For %%i in (%serverlist%) do call :dumplog %%i endlocal goto :EOF :dumplog set server=%1 BEGIN COMMENT LINE ::.Check to see whether the output directory exists, and if it doesn't, create it. END COMMENT LINE :: BEGIN CALLOUT B IF NOT EXIST \\%server%\c$\logs\seclog Echo Creating \\%server%\c$\logs\seclog…& MD \\%server%\c$\logs\seclog :: END CALLOUT B Echo Dumping Security Log for %server%... BEGIN COMMENT LINE :: Dump Security log of %server%, then clear the Security logs. END COMMENT LINE :: BEGIN CALLOUT C psloglist -s -c \\%server% security | find /I "," >> \\%server%\c$\logs\seclog\%server%_%filedate%.txt :: END CALLOUT C Echo Zipping Security Log for %server%... BEGIN COMMENT LINE :: Move the generated text file into the .zip archive. END COMMENT LINE :: BEGINCALLOUT D zip -j -m \\%server%\c$\logs\seclog\%server%_SECLOG_%zipdate%.zip \\%server%\c$\logs\seclog\*.txt :: END CALLOUT D goto :EOF