Thursday, January 04, 2007

Using the cmdshell to add an e-mail address

Thought this was interesting in the Exchange help file.

It is not possible to add an e-mail address with a single command using the Set-Mailbox cmdlet. To add an e-mail address to an existing mailbox, you need to store the mailbox configuration in a variable and modify the EmailAddresses field of that variable. There are two ways to modify the EmailAddresses field of the temporary variable. The following example shows both ways to add two additional addresses to the user john@contoso.com:

$Temp = Get-Mailbox -Identity
$Temp.EmailAddresses.Add("smtp:john@secondaddress.contoso.com")
$Temp.EmailAddresses += ("smtp:john@thirdaddress.contoso.com")
Set-Mailbox -Instance $Temp


Of course the GUI will allow simple modifications as you've done before.