System Administration Scripting

2007年4月29日星期日

自动禁用两个月未登录的用户并保留操作记录

On Error Resume Next
Dim sList, sServer
sList = Array("SERVER1","SERVER2","SERVER3")
For Each sServer in sList
Set oDomain = GetObject("WinNT://" & sServer)
oDomain.Filter = Array("User")
WScript.Echo "服务器" & oDomain.Name & "帐户禁用详细记录:" & vbNewLine
For Each oDomainItem In oDomain
sUsrLogin = oDomainItem.LastLogin
Set oUsr = GetObject("WinNT://" & sServer & "/" & oDomainItem.Name & ",user")
If oUsr.LastLogin > sUsrLogin Then
sUsrLogin = oUsr.LastLogin
End If

If DateDiff("d", sUsrLogin, Now) > 60 Then
WScript.Echo oDomainItem.Name & "上一次登录时间为:" & FormatDateTime(sUsrLogin, 2)
WScript.Echo oDomainItem.Name & "已经有六十多天未曾使用了。"
oUsr.AccountDisabled = True
oUsr.SetInfo
WScript.Echo oDomainItem.Name & "帐户已禁用!"
End If
Next
WScript.Echo "帐户禁用操作执行于:" & now
Next

Bookmark this post:
Ma.gnolia DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google


0 评论:

相关文章

©2007