如何列出具有任意传递选项的 Exchange 2003 帐户

如何列出具有任意传递选项的 Exchange 2003 帐户

我正在寻找一种方法来列出在 Exchange 2003 中设置了任何传递选项的帐户。
我使用 WMI 查询了以下 Exchange 类:http://msdn.microsoft.com/en-us/library/aa142577(EXCHG.65).aspx但到目前为止我还没有找到任何与交付选项相关的属性。

谢谢!

答案1

您需要更具体地指定您想要的传递选项,因为有几种。不过,我会给您这个 VBScript,它将为您提供 Active Directory 中设置了转发邮箱的每个用户。

我已经在虚拟机中测试过它,它运行得相当快,但适用通常的规则。请在生产环境中运行之前在实验室环境中进行测试,并且对于运行此脚本时世界因自身重量而崩溃的情况,我不承担任何责任。

在命令行上调用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

相关内容