标题: 如何在目录中查找邮箱的GUID [打印本页] 作者: steels 时间: 2005-12-16 10:25 标题: 如何在目录中查找邮箱的GUID msExchMailboxGUID ?作者: steels 时间: 2005-12-16 13:40 标题: 搞好了,发出来大家共享! '===============================================================<br>
' Purpose: Display each Exchange_Mailbox found for Exchange server,<br>
' and show the MailboxGUID property on the Exchange_Mailbox<br>
' objects<br>
' Change: cComputerName [string] the computer to access<br>
' Output: Displays the name of each Exchange_Mailbox's MailboxGUID property<br>
'===============================================================<br>
<br>
On Error Resume Next<br>
Dim cComputerName<br>
Const cWMINameSpace = "root/MicrosoftExchangeV2"<br>
Const cWMIInstance = "Exchange_Mailbox"<br>
cComputerName = "YourComputerNameofExchange"<br>
<br>
Dim strWinMgmts ' Connection string for WMI<br>
Dim objWMIExchange ' Exchange Namespace WMI object<br>
Dim listExchange_Mailboxs ' ExchangeLogons collection<br>
Dim objExchange_Mailbox ' A single ExchangeLogon WMI object<br>
<br>
' Create the object string, indicating WMI (winmgmts), using the<br>
' current user credentials (impersonationLevel=impersonate),<br>
' on the computer specified in the constant cComputerName, and<br>
' using the CIM namespace for the Exchange provider.<br>
strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& _<br>
cComputerName&"/"&cWMINameSpace<br>
Set objWMIExchange = GetObject(strWinMgmts)<br>
' Verify we were able to correctly set the object.<br>
If Err.Number <> 0 Then<br>WScript.Echo "ERROR: Unable to connect to the WMI namespace."<br>
Else<br>'<br>' The Resources that currently exist appear as a list of<br>' Exchange_Mailbox instances in the Exchange namespace.<br>Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance)<br>'<br>' Were any Exchange_Mailbox Instances returned?<br>If (listExchange_Mailboxs.count > 0) Then<br>' If yes, do the following:<br>' Iterate through the list of Exchange_Mailbox objects.<br>For Each objExchange_Mailbox in listExchange_Mailboxs<br>Wscript.Echo"MailUserName = "&objExchange_Mailbox.MailboxDisplayName<br>'<br>' Display the value of the MailboxGUID property.<br>WScript.echo "MailboxGUID = "& _<br>" ["&TypeName(objExchange_Mailbox.MailboxGUID)&"] "& _<br>objExchange_Mailbox.MailboxGUID<br>'<br>Next<br>Else<br>' If no Exchange_Mailbox instances were returned,<br>' display that.<br>WScript.Echo "WARNING: No Exchange_Mailbox instances were returned."<br>End If<br>
End If<br>
<br>