How to Bulk Create Microsoft Entra Users with Microsoft Graph PowerShell
Question details
The user needs to bulk create Microsoft Entra users by importing a CSV file using the Microsoft Graph PowerShell SDK, transitioning away from legacy MSOnline commands.

- Product
- Microsoft Entra ID
- Device & OS
- not provided
- Scenario
- Importing a batch of user accounts into Microsoft Entra using a CSV file and modern Microsoft Graph PowerShell cmdlets.
- Observed behavior
- To succeed, the user must format the CSV with required properties, authenticate using Connect-MgGraph with proper permissions, and use New-MgUser to create the accounts.
Ensure you have the Microsoft Graph PowerShell SDK installed and have access to an account with User Administrator or Global Administrator privileges.
Bulk Import Users using Connect-MgGraph and New-MgUser
Use the updated Microsoft Graph PowerShell commands to authenticate, parse a CSV file, and bulk create user accounts.
The Microsoft Graph PowerShell SDK replaces legacy modules like MSOnline. You will need to prepare a properly formatted CSV file and authenticate with the correct delegated permissions before running the import commands.
Create a CSV file using a spreadsheet editor. Ensure the first row contains the required headers: UserPrincipalName, DisplayName, MailNickname, and AccountEnabled.
Open PowerShell as an Administrator and run 'Connect-MgGraph -Scopes "User.ReadWrite.All"'. Sign in using your User Administrator or Global Administrator credentials.
Use the 'Import-Csv' cmdlet to read your prepared file, and pipe the data into a loop utilizing the 'New-MgUser' cmdlet to create each individual user.
Once the import completes, execute 'Disconnect-MgGraph' to securely close the session and prevent your permissions or credentials from remaining cached.

Prepare Your Admin CSV Files Seamlessly with WPS Office
While Microsoft Graph handles your tenant administration, you need a reliable spreadsheet editor to prepare your user import CSV files. WPS Office is a lightweight, free alternative to Microsoft Office that easily handles CSV and Excel files.

Frequently Asked Questions
What headers are strictly required in the CSV file for New-MgUser?
At a minimum, your CSV file must contain columns for UserPrincipalName, DisplayName, MailNickname, AccountEnabled, and a password profile configuration to successfully create a new user profile.
Why am I getting an 'Insufficient privileges' error when running New-MgUser?
This error occurs when the signed-in account lacks the required directory permissions. You must run Connect-MgGraph with the User.ReadWrite.All scope using a Global Administrator or User Administrator account.
Can I still use New-MsolUser to create users from a CSV?
Microsoft is actively deprecating the legacy MSOnline (MSOL) modules. It is highly recommended to update your scripts to use the Microsoft Graph PowerShell SDK cmdlets, such as New-MgUser.




