logo
search
Others

How to Bulk Create Microsoft Entra Users with Microsoft Graph PowerShell

Phi Hung VoPhi Hung Vo Oct 14, 2026 869 views

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.

How to Bulk Create Microsoft Entra Users with Microsoft Graph PowerShell
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.
Before you start

Ensure you have the Microsoft Graph PowerShell SDK installed and have access to an account with User Administrator or Global Administrator privileges.

Solution 1Recommended

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.

1
Prepare your CSV file

Create a CSV file using a spreadsheet editor. Ensure the first row contains the required headers: UserPrincipalName, DisplayName, MailNickname, and AccountEnabled.

2
Connect to Microsoft Graph

Open PowerShell as an Administrator and run 'Connect-MgGraph -Scopes "User.ReadWrite.All"'. Sign in using your User Administrator or Global Administrator credentials.

3
Run the import and creation commands

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.

4
Disconnect the active session

Once the import completes, execute 'Disconnect-MgGraph' to securely close the session and prevent your permissions or credentials from remaining cached.

Bulk Import Users using Connect-MgGraph and New-MgUser
Resolving Permission Errors: If you receive an 'Insufficient privileges to complete the operation' error, run Disconnect-MgGraph to clear out any cached incorrect permissions, then reconnect using an account with admin rights.
Free Microsoft Office alternative

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.

Fully compatible with Microsoft Excel formats (.xlsx, .csv) for preparing flawless user import templates.Completely free and lightweight, allowing you to open and edit large CSV data sets instantly.Features a familiar, intuitive interface with zero learning curve for traditional Office users.
microsoft office alternative - wps office

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.