creating bulks mailboxes

%3CLINGO-SUB%20id%3D%22lingo-sub-1747372%22%20slang%3D%22en-US%22%3Ecreating%20bulks%20mailboxes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1747372%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ecan%20you%20assist%20me%20with%20detailed%20and%20simple%20scrip%20to%20create%20bulk%20mailboxes%3F%20We%20have%20a%20hybrid%20environment.%20Exchange%202013.%20i%20assign%20the%20license%20in%20365.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1747372%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Ehybrid%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1748148%22%20slang%3D%22en-US%22%3ERe%3A%20creating%20bulks%20mailboxes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1748148%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821104%22%20target%3D%22_blank%22%3E%40Dianna1T%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20a%20quick%20simple%20powershell%20script%20that%20will%20create%20the%20users%20on%20preim%20and%20enable%20mailboxes%20in%20the%20cloud%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Efor%20(%24users%3B%24Users%20-le%2010%3B%24Users%2B%2B)%7B%0A%0A%24BulkName%3D%22MyBulk%24(%24users)%22%0A%24UPN%3D%24BulkName%2B%22%40%22%2B%24env%3AUSERDNSDOMAIN%0A%24RemoteRouting%3D%22smtp%3A%24(%24BulkName)%40MyOrgtenant.mail.onmicrosoft.com%22%20%20%23Change%20the%20MyOrgTenant%20with%20a%20proper%20one%0ANew-ADUser%20-DisplayName%20%24BulkName%20%20-AccountPassword%20(ConvertTo-SecureString%20-String%20'P%40ssw0rd'%20-AsPlainText%20-Force)%20-SamAccountName%20%24BulkName%20-Name%20%24BulkName%20-UserPrincipalName%20%24UPN%20-Enabled%20%24true%0AEnable-RemoteMailbox%20-Identity%20%24BulkName%20-RemoteRoutingAddress%20%24RemoteRouting%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E---------------------%3C%2FP%3E%3CP%3EIf%20you%20find%20this%20reply%20helpful%2C%20please%20give%20it%20a%20like%20or%20click%20on%20Best%20Response%20if%20it%20was%20the%20best%20answer.%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1749532%22%20slang%3D%22en-US%22%3ERe%3A%20creating%20bulks%20mailboxes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1749532%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F790105%22%20target%3D%22_blank%22%3E%40farismalaeb%3C%2FA%3E%26nbsp%3BThank%20you%20for%20your%20response%2C%20can%20you%20explain%20to%20me%20the%20scrip%20I%20not%20savvy%20reading%20scripts.%20So%20I%20would%20not%20know%20what%20to%20change%20on%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1750884%22%20slang%3D%22en-US%22%3ERe%3A%20creating%20bulks%20mailboxes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1750884%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821104%22%20target%3D%22_blank%22%3E%40Dianna1T%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Bold%20is%20the%20explination%3C%2FP%3E%3CP%3Efor%20(%24users%3B%24Users%20-le%2010%3B%24Users%2B%2B)%7B%26nbsp%3B%3CSTRONG%3ELoop%20start%20here%2C%20with%20a%20variable%20named%20%24user%20and%20the%20loop%20will%20keep%20in%20running%20and%20increasing%20the%20value%20of%20%24user%20with%201%20as%20long%20as%20its%20less%20or%20equal%20(-le)10.%20The%20loop%20will%20start%20from%200%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%24BulkName%3D%22MyBulk%24(%24users)%22%26nbsp%3B%3CSTRONG%3ETheName%20of%20the%20user%20and%20the%20Increment%20number%20from%20the%20loop%20above%3C%2FSTRONG%3E%3CBR%20%2F%3E%24UPN%3D%24BulkName%2B%22%40%22%2B%24env%3AUSERDNSDOMAIN%20%23%3CSTRONG%3EBuilding%20the%20UPN%20for%20the%20user%2C%20the%20%24Env%3AUSERDNSDOMAIN%2C%20will%20fetch%20the%20domain%20name%20as%20the%20UPN%20should%20be%20username%40domain%3C%2FSTRONG%3E%3CBR%20%2F%3E%24RemoteRouting%3D%22smtp%3A%24(%24BulkName)%40MyOrgtenant.mail.onmicrosoft.com%22%20%3CSTRONG%3E%23Change%20the%20MyOrgTenant%20with%20a%20proper%20one%2C%20its%20your%20external%20tenant%20name%20%3A)%3C%2Fimg%3E%3C%2FSTRONG%3E%3CBR%20%2F%3ENew-ADUser%20-DisplayName%20%24BulkName%20-AccountPassword%20(ConvertTo-SecureString%20-String%20'P%40ssw0rd'%20-AsPlainText%20-Force)%20-SamAccountName%20%24BulkName%20-Name%20%24BulkName%20-UserPrincipalName%20%24UPN%20-Enabled%20%24true%20%23%3CSTRONG%3ECreating%20an%20On-premise%20AD%20user%20using%20the%20variable%20above%20and%20a%20default%20password%20which%20is%20P%40ssw0rd%3C%2FSTRONG%3E%3CBR%20%2F%3EEnable-RemoteMailbox%20-Identity%20%24BulkName%20-RemoteRoutingAddress%20%24RemoteRouting%26nbsp%3B%3CSTRONG%3E%23Enable%20this%20user%20to%20have%20an%20email%20on%20the%20Exchange%20Online%2C%20But%20you%20will%20need%20to%20make%20sure%20that%20the%20ADSync%20include%20the%20User%20Container%20as%20this%20script%20will%20place%20the%20user%20there%2C%20if%20you%20don't%20want%20that%20you%20can%20change%20the%20default%20location.%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E%23After%20the%20script%20finish%2C%20just%20wait%20for%20sometime%20till%20the%20ADSync%20finish%20and%20you%20will%20find%20the%20user%20on%20Exchange%20Online%2C%20Please%20make%20sure%20that%20you%20run%20this%20with%20Exchange%20Management%20shell%20loaded%2C%26nbsp%3B%20(Exchange%20Management%20Shell)%3C%2FSTRONG%3E%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E---------------------%3C%2FP%3E%3CP%3EIf%20this%20answer%20solved%20your%20issue%2C%20please%20click%20Best%20Response%20and%20give%20me%20a%20thumb%20up%20by%20clicking%20like%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello,

 

can you assist me with detailed and simple scrip to create bulk mailboxes? We have a hybrid environment. Exchange 2013. i assign the license in 365. 

3 Replies
Highlighted

@Dianna1T 

This is a quick simple powershell script that will create the users on preim and enable mailboxes in the cloud

for ($users;$Users -le 10;$Users++){

$BulkName="MyBulk$($users)"
$UPN=$BulkName+"@"+$env:USERDNSDOMAIN
$RemoteRouting="smtp:$($BulkName)@MyOrgtenant.mail.onmicrosoft.com"  #Change the MyOrgTenant with a proper one
New-ADUser -DisplayName $BulkName  -AccountPassword (ConvertTo-SecureString -String 'P@ssw0rd' -AsPlainText -Force) -SamAccountName $BulkName -Name $BulkName -UserPrincipalName $UPN -Enabled $true
Enable-RemoteMailbox -Identity $BulkName -RemoteRoutingAddress $RemoteRouting
}

 

---------------------

If you find this reply helpful, please give it a like or click on Best Response if it was the best answer.

Thanks

 

Highlighted

@farismalaeb Thank you for your response, can you explain to me the scrip I not savvy reading scripts. So I would not know what to change on it.

Highlighted

@Dianna1T 

The Bold is the explination

for ($users;$Users -le 10;$Users++){ Loop start here, with a variable named $user and the loop will keep in running and increasing the value of $user with 1 as long as its less or equal (-le)10. The loop will start from 0

$BulkName="MyBulk$($users)" TheName of the user and the Increment number from the loop above
$UPN=$BulkName+"@"+$env:USERDNSDOMAIN #Building the UPN for the user, the $Env:USERDNSDOMAIN, will fetch the domain name as the UPN should be username@domain
$RemoteRouting="smtp:$($BulkName)@MyOrgtenant.mail.onmicrosoft.com" #Change the MyOrgTenant with a proper one, its your external tenant name :)
New-ADUser -DisplayName $BulkName -AccountPassword (ConvertTo-SecureString -String 'P@ssw0rd' -AsPlainText -Force) -SamAccountName $BulkName -Name $BulkName -UserPrincipalName $UPN -Enabled $true #Creating an On-premise AD user using the variable above and a default password which is P@ssw0rd
Enable-RemoteMailbox -Identity $BulkName -RemoteRoutingAddress $RemoteRouting #Enable this user to have an email on the Exchange Online, But you will need to make sure that the ADSync include the User Container as this script will place the user there, if you don't want that you can change the default location. 

#After the script finish, just wait for sometime till the ADSync finish and you will find the user on Exchange Online, Please make sure that you run this with Exchange Management shell loaded,  (Exchange Management Shell)
}

 

 

---------------------

If this answer solved your issue, please click Best Response and give me a thumb up by clicking like :)