question

RuneOksnes-5975 avatar image
0 Votes"
RuneOksnes-5975 asked RuneOksnes-5975 commented

Bulk add extra smtp with prefix

We are still on prem exchange 2016.

I need to bulk add one extra smtp with prefix like something.alias@domain.com
I would also point this to on OU in AD
My default email address policy ia pointing to all exchange users, so I would like to avoid that.

I looked into:

Get-User -OrganizationalUnit "OU" | % { Set-Mailbox $.UserPrincipalName -EmailAddresses @{add="$("something").$($.FirstName).$($_.LastName)@domain.com"}}

But we are using æ,ø and å here so that was not the way.

I tried to replace ($.FirstName).$($.LastName) with ($_.alias), but since that is an exchange attribute, no success.

Anyone got input to me? Is there a way to get-mailbox selected from OrganizationalUnit and return with something.alias@domain.com?


Thank you in advance

office-exchange-server-mailflowoffice-exchange-server-itpro
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello Rune,
not sure, if this is just a typo or copy/paste error, but when pipng to foreach (%), you need to use the "this" variabe "$".
Means:
Get-User -OrganizationalUnit "OU" | % { Set-Mailbox $
.UserPrincipalName -EmailAddresses @{ add="smtp:something.$($.FirstName).$($.LastName)@domain.com" } }

And there is a limitation to valid characters in the smtp local part.
A very good explanation here:
https://social.technet.microsoft.com/Forums/exchange/en-US/69f393aa-d555-4f8f-bb16-c636a129fc25/what-are-valid-and-invalid-email-address-characters
a nice table here: https://www.jochentopf.com/email/chars.html
if you prefer WIkiPedia with examples and references:
https://en.wikipedia.org/wiki/Email_address

I hope, this helps!
Cheers, Alex

0 Votes 0 ·

ok, I just realize that the dash "_" is being removed from the code when clicking submit... too bad...
so in words, this would be like:
Dollar Dash Dot <propertyname>

0 Votes 0 ·

1 Answer

AlexC-8264 avatar image
0 Votes"
AlexC-8264 answered RuneOksnes-5975 commented

Hi Rune,
sure, just exchange Get-User by Get-Mailbox .. you can filter for -OrganizationalUnit too, but then can use the .Alias property for the syntax above.
Alex

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you, closing in here now. But is there any chance of replacing ($.FirstName).$($.LastName)@domain.com" with $($.alias)@domain.com"
That would be my voila!
feelin uncertain since I now enter both the Exchange part and the Active Directory part, and the alias will not be piped from the get-user part.
Do not misunderstand, your answer works out fine, but we have Æ.Ø and Å in our names, that is risky business. Øyvind or Åge is not equal to what is the currently alias, where we use oyvind or Age.

0 Votes 0 ·

ahhhhhh. a second brain is underrated. Thank you very much!

0 Votes 0 ·

very welcome!
my second brain / memory extension for cmdlets is docs.microsoft.com .. ;o)

0 Votes 0 ·