Monday, July 1, 2013

Creating Additional SMTP Addresses For Exchange Users

I recently had to add an additional SMTP Address for all the users in my domain. I wrote this quick script that made it a no brainer:

<#
.NAME
    Append-EmailAddresses.ps1
.SYNOPSIS
    This script adds a new smtp address of first.last@exchange.yourdomain.com
    to all email users that have an @yourdomain.com email address
.DESCRIPTION 
  Versions
    1.0 - 12/21/2011 Initial release
.LINK
    http://unicomsta.blogspot.com/
.EMAIL
    sean.mcnamara@live.com
.EXAMPLE
    .\Append-EmailAddresses.PS1
.INPUTS
    None. You cannot pipe objects to this script.
#>

$mailboxes = Get-Mailbox -resultsize unlimited -RecipientTypeDetails UserMailbox"
foreach ($mailbox in $mailboxes)
{
  
$newaddress = $mailbox.windowsemailaddress -replace '@yourdomain.com' , '@exchange.yourdomain.com'

$mailbox.EmailAddresses += $newaddress

Set-Mailbox -Identity $mailbox.alias -EmailAddresses $mailbox.EmailAddresses
}

No comments:

Post a Comment

Thanks for reading and commenting. I look forward to it.