个人资料
正文

[Original] Windows script to log user, computer name, serial num

(2019-05-09 10:50:40) 下一个

::login script used by system admins to collect user name,computer name,data,time and serial number for each login.
@echo off
if not exist "\dc-srvr01logsLoginsLoginLogs.csv" goto end
for /f "usebackq tokens=3 delims=," %%a in (`getmac /fo csv /v ^| find "cpip"`) do set MAC=%%~a
for /f "tokens=2 delims==" %%i in ('wmic bios get serialnumber /VALUE ^| find "Number"') do set SerialNumber=%%i
for /f "tokens=3,4,5 delims= " %%j in ('reg query "HKLMSoftwareMicrosoftWindows NTCurrentVersion" /v ProductName ^| find "ProductName"') do (set OS=%%j %%k %%l)
FOR /F "tokens=4 delims= " %%n in ('route print ^| find "0.0.0.0" ^| find "Default" /v ^| find "On-link" /v') do set localIp=%%n
for /f "tokens=2 delims==." %%c in ('wmic OS Get localdatetime /value ^|findstr /r [0-9]')do (set _date=%%c)
set year=%_date:~0,4%
set month=%_date:~4,2%
set day=%_date:~6,2%
echo %year%-%month%-%day%,%time%,%username%,%computername%,%MAC%,%localIp%,%OS%,%SerialNumber% >> \dc-srvr01logsLoginsLoginLogs.csv
:end

[ 打印 ]
阅读 ()评论 (0)
评论
目前还没有任何评论
登录后才可评论.