I'm looking for a way to list the accounts that have any delivery option set in Exchange 2003.
I have used WMI to query the Exchange classes described at http://msdn.microsoft.com/en-us/library/aa142577(EXCHG.65).aspx but so far I haven't found any properties related to the delivery options.



1 Answer 1


You'll need to specify a bit more specifically what delivery options you want, as there are several. I'll give you this VBScript though, which will give you every user in your Active Directory who has a forwarding mailbox set.

I've tested this in a VM and it runs pretty quickly, but usual rules apply. Please test in a lab environment before running in production, and I take no responsibility for the world collapsing under its own weight when you run this script.

Invoke on the command line with 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"
End If

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .