DEV Community

Ranjit Rimal
Ranjit Rimal

Posted on

Bulk User Creation & License Assignment via PowerShell

Microsoft 365 Business Basic represents a modern philosophical shift in how we perceive work and collaboration—moving from isolated effort to interconnected productivity. It embodies the principle that technology should empower people, regardless of scale, to communicate, share, and create with ease and purpose. By offering cloud-based tools like Teams, Exchange, and OneDrive, it democratizes access to professional-grade digital infrastructure, supporting the ideals of inclusivity, agility, and meaningful connection in the evolving landscape of human enterprise.

We have put the script for bulk user creation and license assignment script from powershell for exchange online that is available in various subscription models.

Connect to Microsoft 365

Connect-MgGraph -Scopes "User.ReadWrite.All", "Directory.ReadWrite.All"

Define new user

$newUser = @{
accountEnabled = $true
displayName = "John Doe"
mailNickname = "johndoe"
userPrincipalName = "johndoe@idreams.ai"
passwordProfile = @{
forceChangePasswordNextSignIn = $true
password = "StrongP@ssword123"
}
usageLocation = "US"
}

Create the user

New-MgUser -BodyParameter $newUser

Assign Microsoft 365 Business Basic license

$license = @{
addLicenses = @(
@{
skuId = "your-sku-id" # Replace with actual SKU ID
}
)
removeLicenses = @()
}

Update-MgUserLicense -UserId "johndoe@idreams.ai" -BodyParameter $license

Top comments (0)