by Clinton at 2013-01-24 02:23:37
Im trying to add a secondary smtp for one user.by toybits at 2013-01-24 03:36:25
I know you can do it with a csv file but i want to do it with command line.
Get-Mailbox | foreach {
$user = Get-Mailbox Clinton
$user.emailAddresses+="clinton@test.com"
Set-Mailbox $user -emailAddresses $user.emailAddresses
}
But it wont work.
I think you have to prefix it with "smtp:"by Takuu at 2013-01-29 05:47:38
Get-Mailbox | foreach {
$user = Get-Mailbox Clinton
$user.emailAddresses+="smtp:clinton@test.com"
Set-Mailbox $user -emailAddresses $user.emailAddresses
}
I had to do something like this for a SIP address and that worked.
You are calling Get-Mailbox once already in the beginning and passing it via pipeline to the foreach structure. You do not need to call it again for each object, because you already have all that data. Now you just have to reference each mailbox object, with $_ later on in the pipeline. Supposing you wanted to assign everyone in your company the same secondary SMTP address (not recommended) you can use this:Get-Mailbox | ForEach-Object {
$user = $
$user.emailAddresses += "smtp:clinton@test.com"
Set-Mailbox $user -emailAddresses $user.emailAddresses
}
But supposing you wanted to give them their own email addresses specific to the user, say for example, in relation to the alias:Get-Mailbox | ForEach-Object {
$user = $
$user.emailAddresses += ("smtp:" + $user.alias + "@test.com")
Set-Mailbox $user -emailAddresses $user.emailAddresses
}