On Error Resume Next将以上代码存为E:\Scripts\UserLastLogin.vbs 具体用法:
Set oDomain = GetObject("WinNT://" & WScript.Arguments(0))
oDomain.Filter = Array("User")
WScript.Echo "服务器" & oDomain.Name & "上所有用户上次登录时间:" & vbCRLF
For Each oDItem In oDomain
Err.Clear
sULogin = oDItem.LastLogin
For k = 1 To (WScript.Arguments.Count - 1)
Set oUsr = GetObject("WinNT://" & WScript.Arguments(k) & "/" & oDItem.Name & ",user")
If oUsr.LastLogin > sULogin Then sULogin = oUsr.LastLogin
Next
If Err.Number = 0 Then WScript.Echo "用户名称:" & oDItem.Name & "最后登录时间:" & FormatDateTime(sULogin)
Next
cscript.exe E:\Scripts\UserLastLogin.vbs //nologo //b SERVER1 SERVER2 SERVER3如果要将结果导出以便保存和分析,可以这样:
cscript.exe E:\Scripts\UserLastLogin.vbs //nologo //b SERVER1 SERVER2 SERVER3 > E:\Script\UserLastLoginStatus.txt
Bookmark this post:
|
0 评论:
发表评论