There’s a few different methods to import users into your Azure tenant.
- In the Azure Active Directory Portal https://aad.portal.azure.com -> Users -> Bulk Operations -> Bulk create
- Or you can use a little powershell
This will focus on the powershell method. Mainly because the Azure Portal only requires point and click. Plus, this is way more fun.
The Sample CSV format:
UserPrincipalName | DisplayName | GivenName | Surname | jobTitle | MailNickName | ObjectId | AccountEnabled | AgeGroup | City | CompanyName | ConsentProvidedForMinor | Country | CreationType | Department | FacsimileTelephoneNumber | IsCompromised | ImmutableId | Mobile | PasswordPolicies | PasswordProfile | PhysicalDeliveryOfficeName | PostalCode | PreferredLanguage | ShowInAddressList | State | StreetAddress | TelephoneNumber | UsageLocation | UserState | UserStateChangedOn | UserType |
nabendun@customdomain.onmicrosoft.com | Nabendu Nahasapeemapetilon | Nabendu | Nahasapeemapetilon | $null | 104667339 | True | Minor | Springfield | null | United States | null | 856-511-6827 | 304-960-7231 | Guder Lao | 2810 | Nepali | Illinois | 43090 Jay Drive | 314-812-4954 | US | Member | ||||||||||
jimboj@customdomain.onmicrosoft.com | Jimbo Jones | Jimbo | Jones | $null | 142259518 | True | Minor | Springfield | null | United States | null | 546-298-0636 | 558-695-5632 | Purabaya | 2810 | Hebrew | Illinois | 39176 Weeping Birch Court | 851-166-3492 | US | Member |
And here’s the sample code below.
Make sure before you run to execute connect-azureAD first!
$CSV = Import-Csv C:\path_to_CSV_file.csv -Delimiter ","
foreach ($User in $CSV) {
$user.UserPrincipalName
$user.DisplayName
$user.GivenName
$user.Surname
$user.jobTitle
$user.MailNickName
$user.ObjectId
$user.AccountEnabled
$user.AgeGroup
$user.City
$user.CompanyName
$user.ConsentProvidedForMinor
$user.Country
$user.CreationType
$user.Department
$user.FacsimileTelephoneNumber
$user.IsCompromised
$user.ImmutableId
$user.Mobile
$user.PasswordPolicies
$user.PasswordProfile
$user.PhysicalDeliveryOfficeName
$user.PostalCode
$user.PreferredLanguage
$user.ShowInAddressList
$user.State
$user.StreetAddress
$user.TelephoneNumber
$user.UsageLocation
$user.UserState
$user.UserStateChangedOn
$user.UserType
Set-AzureADUser -ObjectID $user.UserPrincipalName `
-jobTitle $User.jobtitle `
-AgeGroup $User.AgeGroup `
-City $User.City `
-CompanyName $User.CompanyName `
-Country $User.Country `
-Department $User.Department `
-FacsimileTelephoneNumber $user.FacsimileTelephoneNumber `
-Mobile $User.Mobile `
-PhysicalDeliveryOfficeName $user.PhysicalDeliveryOfficeName `
-Postalcode $user.PostalCode `
-State $user.state `
-Streetaddress $user.StreetAddress `
-TelephoneNumber $user.TelephoneNumber `
-UsageLocation $user.UsageLocation
write-output $User
}