■せっかくはてなのデスクトップクラウドのキャンペーンに当たったので。。。
■githubに置きました。
https://github.com/labunix/windows2012server
■debug版だけで充分かも知れませんが、
異常終了時に以降のコマンドを実行しないwincheck.batがメインです。
■debianからアップロードするのに、念のためzipにしてあります。
以下に「wincheck_debug.bat」を出しておきます。
「1_date.log」は常に空ファイルです。気になる方は以下のように時間でも入れて下さい。
> time /T > %NUM%_date.log
> type wincheck_debug.bat
@echo off
echo
echo
echo
echo
echo
@echo on
set NUM=0
cd /d %~dp0
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
set MYDATE=%date:~0,4%%date:~5,2%%date:~8,2%
dir /b/ad "%MYDATE%_%COMPUTERNAME%" >NUL 2>NUL || mkdir "%MYDATE%_%COMPUTERNAME%"
dir /b/ad "%MYDATE%_%COMPUTERNAME%" >NUL 2>NUL && cd "%MYDATE%_%COMPUTERNAME%"
echo . 2> %NUM%_date.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
systeminfo /FO CSV > %NUM%_systeminfo.csv
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
net start > %NUM%_net_start.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
sc query | findstr "^D" > %NUM%_sc_query.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
sc query | findstr "^S" >> %NUM%_sc_query.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
driverquery /FO CSV > %NUM%_drivequery.csv
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
net user > %NUM%_net_user.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
wmic qfe > %NUM%_wmic_qfe.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s | findstr "DisplayName" | findstr /V "更新 修正 (KB" > %NUM%_Uninstall.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
powershell import-module servermanager
powershell get-windowsfeature > %NUM%_getwindowsfeature_all.log
powershell get-windowsfeature | find "[X]" > %NUM%_getwindowsfeature.log
if ERRORLEVEL 1 echo ERROR %NUM%
set /a NUM=%NUM%+1
@echo off
echo
echo
echo
echo
echo
@echo on
if EXIST ..\runwincheck_debug.bat.log type ..\runwincheck_debug.bat.log > "%NUM%_%MYDATE%_%COMPUTERNAME%.log"
if ERRORLEVEL 1 echo ERROR %NUM%
echo 正常終了 >> "%NUM%_%MYDATE%_%COMPUTERNAME%.log"