Hi,
I'm trying to create a script that gets all user mailboxes in Exchange 2010, then adds an additional custom SMTP address (SIP) without removing any existing email address. If I run the script for one user, it works fine (below)
This works for an individual user:
$SIPUsers = Get-Mailbox -Identity user
ForEach ($user in $SIPUsers)
{
$SIPUsers.EmailAddresses += "SIP:" + $user.SamAccountName + "@domain.org"
Set-Mailbox -Identity $user -EmailAddresses $SIPUsers.EmailAddresses
}
When I run this script (below), it removes all SMTP address, x500, custom secondary alias etc and applies the default email policy. I do get an error as well, which is:
$SIPUsers = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize unlimited
ForEach ($user in $SIPUsers)
{
$SIPUsers.EmailAddresses += 'SIP:' + $user.SamAccountName +'@ynhh.sso.ynhh.org'
Set-Mailbox -Identity $user -EmailAddresses $SIPUsers.EmailAddresses
}
Error:
Property 'EmailAddresses' cannot be found on this object; make sure it exists and is settable.
At C:\Scripts\SIPAdd.ps1:5 char:15
+ $SIPUsers. <<<< EmailAddresses += "SIP:" + $user.SamAccountName + "@ynhh.sso.ynhh.org"
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException