Back to script samples page
Importing users with minimum user details using a CSV file

The best way to bulk add new users is by using PowerShell.
To import a large number of users, you need to first prepare a CSV file with the relevant user information.

The minimum required field information to create a user is a Display Name, and a User Principal Name (UPN) in the format

Prepare a .CSV file (named Import_new_user_Basic.csv for example) with the following comma delimited format: UserPrincipalName, DisplayName or use the sample file provided in this scenario section.

#Importing users with minimum user details using a CSV file

#This first command will import the Azure Active Directory module into your PowerShell session.
Import-Module MSOnline

#Capture administrative credential for future connections.
$credential = get-credential

#Establishes Online Services connection to Azure Active Directory  
Connect-MsolService -Credential $credential

#This command Imports the users in your prepared CSV file. 
#It assumes the CSV file is located in the same directory as your current powershell session, with the following two column headers: UserPrincipalName, DisplayName. Each new user should be on a new row of the CSV. 
#Note that as we are not stipulating a password, one will be generated automatically by Office 365.
Import-Csv .\Import_new_user_Basic.csv | ForEach-Object { New-MsolUser -UserPrincipalName $_.UserPrincipalName -DisplayName $_.DisplayName }
Downloaded 0 times
- - - - - (0)

No Comments