Bulk enable the AD mail user using PowerShell ?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ITEngineer
Posts: 216
Last visit: Thu Mar 23, 2023 5:45 pm
Has voted: 4 times

Bulk enable the AD mail user using PowerShell ?

Post by ITEngineer »

Hi All,

I need some assistance in the bulk PowerShell script to enable some of the users that have been provisioned in the Office 365 Exchange Online, but does not have the OnPremise Exchange mailbox:

This is the one-liners that I must execute manually one by one for every new user provisioned in the Office365:

Source OU:
OU=Global Users,DC=CompanyA,DC=com (225 users in total)

Code: Select all

Enable-Mailuser -Identity samAccountName -primarySMTPAddress First.Last@CompanyA.com -ExternalEmailAddress First.Last@GlobalCompanyLtd.onmicrosoft.com 
OU=Global Users,DC=CompanyB,DC=com (182 users in total)

Code: Select all

Enable-Mailuser -Identity samAccountName -primarySMTPAddress First.Last@CompanyB.com -ExternalEmailAddress First.Last@GlobalCompanyLtd.onmicrosoft.com 
The samAccountName is in the format of First.LastName.

Thanks in advance for assisting me in enabling the bulk users with the script.
/* IT Engineer */
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Bulk enable the AD mail user using PowerShell ?

Post by jvierra »

Just execute the command in a loop once for each user.
This topic is 5 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked