切换到宽版
  • 6838阅读
  • 0回复

[求助]使用脚本清理已经断开连接的邮箱 [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2011-03-13
— 本帖被 YOYO 从 Exchange 脚本中心 移动到本区(2015-06-25) —
  • 脚本环境:Visual Basic
  • 适合版本:Exchange 2003
  • 适用平台:
  • 脚本作用:清理已经断开连接的邮箱
使用此脚本可以对已经断开连接的邮箱进行清理。


' 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


分享到
快速回复
限60 字节
 
上一个 下一个