We want to delete all Email Architect User where the last login in Email Account older than 3 Month is.
Is there any Solution ?
Thanks Peter
cbspeda wrote:
Please copy the following to notepad
then change your password
Option Explicit
Dim host, sysuser, password, domain, user, emailaddr
host = "localhost"
sysuser = "system"
password = "systempassword"
Dim inactivedays
inactivedays = 90 '3 months no logon
domain = "*" 'seach in all domains, you can also specify the domain name to seach
Dim oSvr
Set oSvr = CreateObject("EmailArchitectObjects.ServerRoot")
Const S_OK = 0
If oSvr.Connect( host, sysuser, password, 0, "127.0.0.1" ) <> S_OK Then
WScript.Echo( "connect server failed." )
WScript.Quit
End If
Dim oDomains, oDomain
Set oDomains = oSvr.DomainCollection
If domain = "*" Then
Dim i, nCount
nCount = oDomains.Count
For i = 0 To nCount-1
Set oDomain = oDomains.Items(CLng(i))
If Not (oDomain Is Nothing) Then
If oDomain.IsAlias = 0 Then
SearchDomain oDomain
End If
End If
Next
Else
Set oDomain = oDomains.Items(CStr(domain))
If Not (oDomain Is Nothing) Then
If oDomain.IsAlias = 0 Then
SearchDomain oDomain
Else
WScript.Echo "you can't search domain alias: " & domain
End If
Else
WScript.Echo "non-existed domain name: " & domain
End If
End If
WScript.Echo( "Completed" )
Sub SearchDomain( ByRef oDomain )
WScript.Echo ""
WScript.Echo "search users in domain: " & oDomain.Name
WScript.Echo ""
Dim lastLogon
Dim i, nCount, oUsers, oUser
Set oUsers = oDomain.UserCollection
Dim bDel
bDel = True
Dim arInactives
nCount = oUsers.Count
ReDim arInactives( nCount + 1 )
Dim n
n = 0
For i = 0 To nCount-1
Set oUser = oUsers.Items(CLng(i))
If Not(oUser Is Nothing) Then
If oUser.IsAlias = 0 Then
lastLogon = oUser.LastLogon
If DateDiff("d", lastLogon, Now() ) > inactivedays Then
oUser.Enabled = 0
oUser.UpdateFields
WScript.Echo oUser.Name
WScript.Echo "Last Logon:" & lastLogon
WScript.Echo "now user is disabled!"
n = n+1
arInactives(n) = oUser.Name
End If
End If
End If
Next
If bDel and n > 0 Then
For i = 1 To n
WScript.Echo arInactives(i) & " deleted!"
WScript.Echo( oUsers.Remove(arInactives(i)))
Next
End If
End Sub
then save it to deleteinactiveuser.vbs or any name with .vbs extension.
Finally, run it in DOS command with
cscript.exe "c:\my script\deleteinactiveuser.vbs"
then it is ok