Getting a list of mailboxes in Exchange 2007/2010
Posted: (EET/GMT+2)
Recently, I needed application code to enumerate all mailboxes in a given domain running Exchange 2007 or 2010. If you have been using or programming these Exchange versions, you know that they rely heavily on PowerShell commands to manage the system. Of course, you can use these same interfaces to help in your own programming efforts.
For instance, my task was to get a list of mailboxes (roughly equal to email addresses) in a domain. The solution is very simple: simply use the Get-Mailbox cmdlet.
This cmdlet work interactively, but you can almost as easily call it using the .NET namespaces System.Management.Automation.*, which are part of the PowerShell installation. Usually, they reside at "C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0".
For more information on how to use these namespaces, visit the MSDN documentation.