Exchange-2003

如何使用任何傳遞選項列出 Exchange 2003 帳戶

  • November 9, 2016

我正在尋找一種方法來列出在 Exchange 2003 中設置了任何傳遞選項的帳戶。

我使用 WMI 來查詢http://msdn.microsoft.com/en-us/library/aa142577 中描述的 Exchange 類( EXCHG.65).aspx但到目前為止我還沒有找到任何與傳遞選項相關的屬性。

謝謝!

您需要更具體地指定您想要的傳遞選項,因為有幾個。不過,我會給你這個 VBScript,它會給你 Active Directory 中每個擁有轉發郵箱集的使用者。

我已經在 VM 中對此進行了測試,它執行得非常快,但適用通常的規則。請在生產環境中執行之前在實驗室環境中進行測試,當您執行此腳本時,我對世界因自身重量而崩潰不承擔任何責任。

在命令行上呼叫cscript /nologo altRecipient.vbs

'************************************************************************************
'* Script to find all users who have alternative recipients set
'*
'* This script was hacked together with information from the following sources.
'* I make no claim of ownership to any part of this script
'*
'*  - http://support.microsoft.com/kb/817433
'*  - http://blogs.technet.com/b/heyscriptingguy/archive/2006/03/22/how-can-i-get-a-list-of-all-the-users-who-have-an-alternate-recipient.aspx
'************************************************************************************

Dim sDomain, sADsPath, sPDC

Dim oCon ,oCmd, oRst
Set oRst = CreateObject("ADODB.Recordset")
Set oCmd = CreateObject("ADODB.Command")
Set oCon = CreateObject("ADODB.Connection")

Dim oRoot, oDomain, oADInfo, oInfo
Set oADInfo = CreateObject("ADSystemInfo")
Set oInfo = CreateObject("WinNTSystemInfo")
sPDC = oInfo.PDC & "." & oADInfo.DomainDNSName

oCon.Provider = "ADSDSOObject"
oCon.Open "Active Directory Provider"

oCmd.ActiveConnection = oCon

Set oRoot = GetObject("LDAP://rootDSE")
sDomain = oRoot.Get("defaultNamingContext")
Set oDomain = GetObject("LDAP://" & sDomain)
sADsPath = "<" & oDomain.ADsPath & ">"

oCmd.CommandText = "SELECT altRecipient, Name FROM 'LDAP://" & sPDC & "/" & sDomain & "' WHERE objectCategory='user' and altRecipient = '*'"
Set oRst = oCmd.Execute

If oRst.RecordCount = 0 Then
   WScript.Echo "no accounts found"
   WScript.Quit
End If

Do While Not oRst.EOF
   WScript.Echo  "User " & oRst.Fields("Name") & " is forwarded to " & oRst.Fields("altRecipient")
   WScript.Echo  "=========================================="
   oRst.MoveNext
Loop

引用自:https://serverfault.com/questions/211242