rem ////////////////////////////////////////////////////// rem 日期:2014.5.26 rem 作者:[email protected] rem 功能: rem 1.当前登录服务器账号: rem 2.当前服务器与时间服务器的时间误差: rem 3.系统启动时间: rem 4.系统打的补丁数量: rem 5.系统未正常启动的自启动服务: rem 6.error event log(24小时内) rem 7.所有磁盘的空余空间百分比 rem rem ////////////////////////////////////////////////////// @echo off setlocal ENABLEDELAYEDEXPANSION set "infoName=INFO_%computername%_%date:~0,4%%date:~5,2%%date:~8,2%" set "infoName=%infoName%.txt" rem ////////////////////////////////////////////////////// >%infoName% echo 1.当前登录服务器账号: >>%infoName% echo ===== >>%infoName% whoami >>%infoName% echo. >>%infoName% echo. rem ////////////////////////////////////////////////////// >>%infoName% echo 2.当前服务器与时间服务器的时间误差: >>%infoName% echo ===== for /f "tokens=1,2* delims=:" %%i in ('ipconfig ^| find "IPv4"') do ( set ip=%%j set ip=!ip: =! >>%infoName% W32TM.EXE /STRIPCHART /COMPUTER:!ip! /SAMPLES:1 ) >>%infoName% echo. >>%infoName% echo. rem ////////////////////////////////////////////////////// >>%infoName% echo 3.系统启动时间: >>%infoName% echo ===== set /a n=0 for /f %%i in ('WMIC PATH Win32_PerfFormattedData_PerfOS_System GET SystemUpTime') do ( set /a n+=1 if !n! equ 2 (set /a d=%%i) ) set /a d=%d%/8640 if %d% GEQ 10 ( set d=%d:~0,-1%.%d:~-1% ) else ( set d=0.%d% ) >>%infoName% echo %d%D >>%infoName% echo. >>%infoName% echo. rem ////////////////////////////////////////////////////// >>%infoName% echo 4.系统打的补丁数量: >>%infoName% echo ===== WMIC PATH Win32_QuickFixEngineering GET HotFixID | FIND /C /I "KB" >>%infoName% >>%infoName% echo. >>%infoName% echo. rem ////////////////////////////////////////////////////// >>%infoName% echo 5.系统未正常启动的自启动服务: >>%infoName% echo ===== setlocal DISABLEDELAYEDEXPANSION if exist ~tmptmp.log (del /f/q ~tmptmp.log) >~tmptmp.log WMIC PATH Win32_Service WHERE (StartMode='Auto' AND State!='Running' AND Name!='SysmonLog') GET Name >>%infoName% type ~tmptmp.log if exist ~tmptmp.log (del /f/q ~tmptmp.log) setlocal ENABLEDELAYEDEXPANSION >>%infoName% echo. >>%infoName% echo. rem ////////////////////////////////////////////////////// >>%infoName% echo 6.error event log(24小时内) >>%infoName% echo ===== set a=%time:~0,2% set year=%date:~0,4% set /a month=%date:~5,2% set /a day=%date:~8,2%-1 if %day% equ 0 ( set /a month=%month%-1 if !month! equ 0 ( set /a year=%year%-1 set /a month=12 set /a day=30 ) else ( if !month! equ 2 ( set /a day=28 ) else ( set /a day=30 ) ) ) if %a% LSS 10 set a=0%a:~1,1% if %month% LSS 10 set month=0%month% if %day% LSS 10 set day=0%day% set t=%year%%month%%day%%a%%time:~3,2%%time:~6,2% if exist ~tmptmp.log (del /f/q ~tmptmp.log) >~tmptmp.log WMIC NTEVENT where 'type="错误" and TimeGenerated^>"%t%.000000-000"' get EventCode, LogFile, SourceName, TimeGenerated, Message, type >>%infoName% type ~tmptmp.log if exist ~tmptmp.log (del /f/q ~tmptmp.log) >>%infoName% echo. >>%infoName% echo. rem ////////////////////////////////////////////////////// >>%infoName% echo 7.所有磁盘的空余空间百分比 >>%infoName% echo ===== for %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do ( if exist %%i: ( set /a n=0 for /f "tokens=1,2" %%x in ('wmic LogicalDisk where ^"Caption^=^'%%i^:^'^" get FreeSpace^,Size') do ( set /a n+=1 if !n! equ 2 ( if %%x neq 0 ( set a=%%x set b=%%y set /a per=!a:~0,-4!/!b:~0,-6! >>%infoName% echo %%i: !per:~0,2!%% ) ) ) ) ) >>%infoName% echo. >>%infoName% echo.
关于Windows server 2008信息收集的批处理脚本
猜你喜欢
转载自blog.csdn.net/end1n9/article/details/27116389
今日推荐
周排行