Bulk enable the AD mail user using PowerShell ?

Ask your Windows 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.
Locked
User avatar
ITEngineer
Posts: 138
Joined: Wed Oct 12, 2011 10:52 am

Bulk enable the AD mail user using PowerShell ?

Post by ITEngineer » Fri Jul 20, 2018 12:12 am

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 */

User avatar
jvierra
Posts: 13395
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Bulk enable the AD mail user using PowerShell ?

Post by jvierra » Fri Jul 20, 2018 12:20 am

Just execute the command in a loop once for each user.

Locked