使用此脚本可以对已经断开连接的邮箱进行清理。
' On Error Resume Next
Dim cComputerName
Dim objWMIService
Dim oDisMbox
Dim mBox
Dim dmBoxes
Dim strAnswer
Const cWMINameSpace = "root/MicrosoftExchangeV2"
Const cWMIInstance = "Exchange_Mailbox"
cComputerName = "SRVEXC01"
strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& _
cComputerName & "/" & cWMINameSpace
Set objWMIService = GetObject(strWinMgmts)
Set oDisMbox = objWMIService.ExecQuery("Select * from Exchange_Mailbox WHERE DateDiscoveredAbsentInDS IS NOT Null")
if oDisMbox.count > 0 then
Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 100
objExplorer.Left = 0
objExplorer.Top = 0
Do While (objExplorer.Busy)
Wscript.Sleep 200
Loop
objExplorer.Visible = 1
objExplorer.Document.Body.InnerHTML = "Mailboxen worden ingelezen, moment...."
For each mBox in oDisMbox
dmBoxes = dmBoxes & mBox.MailboxDisplayName & ", "
Next
strAnswer = MsgBox("Volgende disconnected Mailboxen gevonden: " & vbCr & vbCr & dmBoxes & vbCr & vbCr & " DOORGAAN ?" , 20, "Purgen ?")
If strAnswer = 6 Then
For each mBox in oDisMbox
objExplorer.Document.Body.InnerHTML = "Mailbox being purged: " & mBox.MailboxDisplayName
mBox.Purge
Next
objExplorer.Document.Body.InnerHTML = "Volgende disconnected mailboxen zijn purged :" & vbCr & vbCr & dmBoxes
Else
objExplorer.Quit
Msgbox "Nothing done..."
Wscript.quit
End If
else
Wscript.echo "No Disconnected Mailboxes found !"
End if
Wscript.Echo "Done !"
Wscript.Sleep 3000
objExplorer.Quit