Powershell to add alias to users mailbox
-
I'm looking to use a powershell script which needs to filter it down to our specific company either buy using our exchange domain (@test.com) or our local domain (test.parentcompany.local) or using the company field in AD Users (I don't think that one's possible). Then it needs to set an alias of the mailbox as First Initial + [email protected]. We currently use [email protected]. The primary email should stay that (the alias should not show up on reply to or anything). Also I need it to handle duplicates by writing a log, How would I do that?
Here's what I've put together so far, not sure if it will work or not..
$Mailboxes = Get-Mailbox –Filter {Emailaddresses –Like "*@test.com"} $Useralias =(($_.FirstName.Substring(0,1)) + ($_.LastName)) Foreach ($Mailbox in $Mailboxes) { $NewAddress = $Useralias + "@test.com" $Mailbox.EmailAddresses += $NewAddress Set-Mailbox -Identity $Mailbox.Alias -EmailAddresses $Mailbox.EmailAddresses }
-
I usually use AD modify for this.. much easier and has a rollback feature in case you mess something up.
http://admodify.codeplex.com/Let me know if that works for you if not then I will look over the script and test it on a clean AD for you.
-
So ADModify will add the second SMTP address to the exchange mailbox but, if you try to send to that it fails. Any ideas why?
When you type the email in the to field in outlook it displays this message at the top "This e-mail message cannot be delivered to Email" because the e-mail address is no longer valid.
-
Do you have any filtering going on in front of Exchange? For example I use Appriver to filter all my incoming mail.
-
@Dashrender said:
Do you have any filtering going on in front of Exchange? For example I use Appriver to filter all my incoming mail.
We have proof point but it just filters Spam https://www.proofpoint.com/ And they aren't showing up in there. We have like 20 domains (from all our companies) on the Exchange server so I can't say I know everything going on, on the exchange servers.
-
Look at your MX records - where is mail being delivered to first? Then walk the delivery path, hopefully you'll find who's hanging you up.
-
@Dashrender said:
Look at your MX records - where is mail being delivered to first? Then walk the delivery path, hopefully you'll find who's hanging you up.
Our public MX Records don't matter internally it goes straight to exchange. Also I'm pretty sure that's not the issue based on it saying "This e-mail message cannot be delivered to EmailAddy because the e-mail address is no longer valid."
-
So if I send it externally it works, just internally it wants you to use the first.last email.
-
And oddly it just started working internally. I guess it just needed a bit more time. (I applied it before lunch).