Exchange Online PS Assistance

Welcome Forums General PowerShell Q&A Exchange Online PS Assistance

Viewing 6 reply threads
  • Author
    Posts
    • #244271
      Participant
      Topics: 1
      Replies: 3
      Points: -1
      Rank: Member

      Hi all

      Can anyone assist me with a few simple PS commands for EOL? It is for around 600 users that are getting an additional email alias.

      Basically what I want to achieve is the following, seems using a properly formatted CSV is the easiest way

      1. Add an alias to a mailbox (this I have managed to figure out)
        1. Import-CSV “C:\Scripts\AddEmailAddress\AddEmailAddress.csv” | ForEach {Set-Mailbox $_.Mailbox -EmailAddresses @{add=$_.NewEmailAddress}}
      2. Set the new alias as primary
      3. Set the new primary alias as their login

      I need help with 2 and 3 and I would like to use a CSV file as the source for everything as it is the current data format.

      Thank you

    • #244346
      Senior Moderator
      Topics: 9
      Replies: 1310
      Points: 4,789
      Helping Hand
      Rank: Community Hero

      I Never worked on exchange, but below links will help you to get it done.

      Setting alias as primary – https://techcommunity.microsoft.com/t5/office-365/powershell-for-replacing-primary-email-address-and-adding/m-p/197844

      I think the alias can be used for login by default (I use alias to login to my outlook account).

      You can have all relevant data in csv and can consume the attributes in the same way you did for step 1 in the same Foreach-Object scriptblock for step 2.

    • #244640
      Participant
      Topics: 1
      Replies: 3
      Points: -1
      Rank: Member

      I Never worked on exchange, but below links will help you to get it done.

      Setting alias as primary – https://techcommunity.microsoft.com/t5/office-365/powershell-for-replacing-primary-email-address-and-adding/m-p/197844

      I think the alias can be used for login by default (I use alias to login to my outlook account).

      You can have all relevant data in csv and can consume the attributes in the same way you did for step 1 in the same Foreach-Object scriptblock for step 2.

      Thank you, I am a total noob at this and those links are quite confusing unfortunately.

    • #244769
      Participant
      Topics: 0
      Replies: 38
      Points: 381
      Helping Hand
      Rank: Contributor

      I’ve messed up formatting on my previous replies and I guess they were scraped, so here is my reply with proper formatting:

      Hello Mark,

      Set the new alias as primary:
      EmailAddresses property show all emails for the mailbox. Primary email is prefixed with SMTP (all caps) and all aliases are prefixed with smtp (all lowercase).
      Example:

      To set some email as Primary you have 3 options:
      1. Use the SMTP prefix on the address

      2. The first email address when you don’t use any prefix values

      So in your case, because you are adding email address to already existing collection of email addresses I would get current primary email address, remove it from collection and added new one with SMTP prefix and old one with smtp prefix.
      Something like this:

      Reference:
      https://docs.microsoft.com/en-us/powershell/module/exchange/set-mailbox?view=exchange-ps

      https://docs.microsoft.com/en-us/exchange/modifying-multivalued-properties-exchange-2013-help

      Regarding #3 please provide more details.

      Hope that helps.

       

    • #244772
      Participant
      Topics: 1
      Replies: 3
      Points: -1
      Rank: Member

      Thank you, this does make sense but how would I script it for 600+ users when not all of them will be receiving the new primary?

      I also considered simply using this command to set them all.

      Set-Mailbox -identity [email protected] -WindowsEmailAddress [email protected] (I am struggling trying to figure out how to use an input file with the old and new addresses like I did with adding the new address)

      Point 3 was their AAD logon that needs to be updated to the same as their primary SMTP.

       

       

    • #244805
      Participant
      Topics: 0
      Replies: 38
      Points: 381
      Helping Hand
      Rank: Contributor

      Mark,

      On order to script it simply rum single command in the loop.

      As for the #3:

      Hope that helps.

      Reference: https://docs.microsoft.com/en-us/powershell/module/exchange/set-mailbox?view=exchange-ps

       

    • #244820
      Participant
      Topics: 1
      Replies: 3
      Points: -1
      Rank: Member

      Mark,

      On order to script it simply rum single command in the loop.

      As for the #3:

      Set-MsolUserPrincipalName -UserPrincipalName “[email protected]” -NewUserPrincipalName “[email protected]” Hope that helps.

      Reference: https://docs.microsoft.com/en-us/powershell/module/exchange/set-mailbox?view=exchange-ps

      Thank you, I also found this as well which seems to work pretty well.

      Set-AzureADUser -objectid [email protected] -UserPrincipalName [email protected]om

Viewing 6 reply threads
  • You must be logged in to reply to this topic.