Scripts & PS

How to Bulk Create Users in Entra ID with PowerShell

Published 16 March 2026 · 7 min read

Creating users one by one in the M365 admin centre works for small teams, but when you need 20, 50, or 200 users at once, PowerShell via the Microsoft.Graph module is the only sensible approach. This guide covers bulk creation from CSV including licence assignment and group membership.

Prerequisites

Install-Module Microsoft.Graph -Scope CurrentUser -Force
Connect-MgGraph -Scopes "User.ReadWrite.All","Group.ReadWrite.All"

Prepare your CSV

FirstName,LastName,Department,JobTitle,UsageLocation
Sarah,Johnson,IT,IT Engineer,GB
Mike,Peters,Finance,Finance Manager,GB

The bulk creation script

$csvPath = "C:\Temp\users.csv"
$domain = "contoso.com"
$tempPassword = "Welcome2026!"

$users = Import-Csv -Path $csvPath
foreach ($user in $users) {
    $upn = "$($user.FirstName.ToLower()).$($user.LastName.ToLower())@$domain"
    $params = @{
        DisplayName       = "$($user.FirstName) $($user.LastName)"
        GivenName         = $user.FirstName
        Surname           = $user.LastName
        UserPrincipalName = $upn
        MailNickname      = "$($user.FirstName.ToLower())$($user.LastName.ToLower())"
        Department        = $user.Department
        JobTitle          = $user.JobTitle
        UsageLocation     = $user.UsageLocation
        AccountEnabled    = $true
        PasswordProfile   = @{ Password = $tempPassword; ForceChangePasswordNextSignIn = $true }
    }
    try {
        New-MgUser @params
        Write-Host "Created: $upn" -ForegroundColor Green
    } catch { Write-Host "Failed: $upn - $_" -ForegroundColor Red }
}

Assign licences

$skuId = (Get-MgSubscribedSku | Where-Object SkuPartNumber -eq "SPB").SkuId
$users = Import-Csv -Path $csvPath
foreach ($user in $users) {
    $upn = "$($user.FirstName.ToLower()).$($user.LastName.ToLower())@contoso.com"
    $mgUser = Get-MgUser -UserId $upn -ErrorAction SilentlyContinue
    if ($mgUser) {
        Set-MgUserLicense -UserId $mgUser.Id -AddLicenses @{SkuId = $skuId} -RemoveLicenses @()
    }
}

Verify

$today = (Get-Date).Date.ToString("yyyy-MM-dd")
Get-MgUser -Filter "createdDateTime ge $today" -All | Select DisplayName, UserPrincipalName

Frequently Asked Questions

Q: Can I bulk create users from the M365 admin centre?

Yes via bulk add with CSV, but it has limited fields and no licence assignment or group membership in the same operation.

Q: What is UsageLocation and why is it required?

UsageLocation is the country code required before assigning a licence. Always include it in your CSV.

Q: How do I handle duplicate UPNs?

Add error handling with try/catch and log failures. Consider including an employee ID in the UPN for uniqueness.

Related Guides
-> Connect M365 with PowerShell-> Graph API Getting Started-> Shared Mailboxes via PS
// need intune set up properly?
Fixed-price Intune setup for UK businesses

App deployment, compliance policies, Conditional Access, and full documentation at a fixed price.

View Packages