I am sharing a small PowerShell script to create at glance Office 365 users in Azure AD and assign them the E3 developer license.
$license = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$license.SkuId = (Get-AzureADSubscribedSku | Where-Object -Property SkuPartNumber -Value "DEVELOPERPACK" -EQ).SkuID
$licenses.AddLicenses = $license
$PasswordProfile=New-Object -TypeName Microsoft.Open.AzureAD.Model.PasswordProfile
$PasswordProfile.Password="YOUR_DEFAULT_PASSWORD"
Import-Csv .\users.csv | foreach-object {
$usernameSplit = $_.UserName.Split("@")
$usernameSplit[0]
$usernameSplit[1]
$userDisplayNameSplit = $usernameSplit[0].Split(".")
$userDisplayNameSplit[0]
$userDisplayNameSplit[1]
$mailNickName = ($usernameSplit[0])
$userprinicpalname = $usernameSplit[0] + "@YOUR_DEV_TENANT_NAME.onmicrosoft.com"
$displayNanme = ($usernameSplit[0] + " " + $usernameSplit[1])
New-AzureADUser -DisplayName $displayNanme -GivenName $userDisplayNameSplit[0] -SurName $userDisplayNameSplit[1] -UserPrincipalName $userprinicpalname -PasswordProfile $PasswordProfile -mailNickName $mailNickName -UsageLocation CH -AccountEnable $true
# Call the Set-AzureADUserLicense cmdlet to set the license.
Set-AzureADUserLicense -ObjectId $userprinicpalname -AssignedLicenses $licenses
}
The cvs file is just one column name UserName containing email in the form of
FIRSTNAME.LASTNAME@company.com
If you have emails in other format you can just modify the lines before the New-AzureADUser command.
Happy coding !