我知道使用事件查看器来检查谁登录系统以及何时登录。但我试图找出一个特定的本地用户帐户,比如管理员 - 该机器上这个特定用户的登录日期和时间是什么。我使用这个脚本,它说我的登录总数,但不是全部。脚本如下。
'Get our list of logons
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile",,48)
'Converts to a readable logon date and time function ConvertTime(sTime)
if (sTime="**************.******+***") then
ConvertTime = "Unknown"
else
if (Trim(sTime)="") then
sTime="Unknown"
else
sYear = Mid(sTime,1,4)
sMonth = Mid(sTime,5,2)
sDay = Mid(sTime,7,2)
sHour = Mid(sTime,9,2)
sMin = Mid(sTime,11,2)
sSec = Mid(sTime,13,2)
end if
ConvertTime = sMonth & "/" & sDay & "/" & sYear & " (" & sHour & ":" & sMin & ":" & sSec & ")"
end if
end function
'Loops through our logon items and only pulls out the
'user accounts...not system accounts that are used
'internally by windows
For Each objItem in colItems
if (objItem.UserType = "Normal Account") then
Wscript.Echo objItem.Name & vbCrLf
Wscript.Echo " Last Logon: " & ConvertTime(objItem.LastLogon)
Wscript.Echo " Number of Logons: " & objItem.NumberOfLogons
if (objItem.Privileges=0) then
WScript.Echo " (Guest Account)"
else if (objItem.Privileges=1) then
WScript.Echo " (Standard User Account)"
else if (objItem.Privileges=2) then
WScript.Echo " (Administrator Account)"
end if
end if
end if
WScript.Echo vbCrLf
end if
Next
编辑以显示预期输出
Username: LocalPC\Administrator
Logon time: ------
Username: LocalPC\Administrator
Logon time: ------
有人可以告诉我如何修改这个脚本,或者有没有其他方法可以尽快以最简单的方式检查它。?提前致谢。