January 27, 2021
Hot Topics:

Enterprise Powershell: Creating Mail-Enabled Contacts in Exchange 2003

  • By Jon Shoberg
  • Send Email »
  • More Articles »

Finally, the big moment arrives; you are now invoking the "MailEnable" member of the CDOEXM assembly. The five-parameter call to invokemember is simple and powerful. Against the assembly you are calling "MailEnable", with the binding flags declared earlier in the script, a null reference to the binder that results in this invocation using the default binding, the native object to which "MailEnable" is being applied, and lastly any arguments that are used during the invocation. Once this step is completed, you modify the user's directory entry by updating the 'altrecipient' and 'forwardingaddress' properties. Finally, upon committing the changes, you'll have a user whose mail will be forwarded according to the mail-enabled contact.

# call the assembly which takes the native object and performs
# MailEnable and commit the change

# set the contact as the mail forward

#output a message stating what has been done
Write-Host "Email for $Account will be forwarded to $email"

#close connections
$Domain_Searcher.dispose   | out-null
$Forward_Container.dispose | out-null

Running this script will produce the following output on the Powershell console, as shown in Figure 1.

Click here for a larger image.

Figure 1: Output on the Powershell console


As your Exchange messaging environment grows and through the course of time, you'll no doubt be asked to diversify mail settings for your current users or ones who no longer have accounts. In either case, this article goes to show how you can use Powershell to interface with some of the more advanced concepts of scripting your Exchange 2003 environment. If you build further on what is presented here, let the author know by emailing him at jonATshobergDOTnet.

About the Author

Jon Shoberg is a developer for The Ohio State University. He has extensive experience in developing enterprise systems in e-commerce, web, and search domains on the LAMP, Java, and .NET platforms. Jon has previously contributed to books and industry publications as a technical reviewer and coauthor, respectively.

Page 2 of 2

This article was originally published on November 16, 2007

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date