Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitManaging licenses for multiple users manually in the Microsoft 365 Admin Center is tedious and error-prone. This script offers a straightforward Graph PowerShell solution to automate license assignment to multiple users by importing them from a CSV file—saving both time and administrative effort.
# Load users from CSV
$users = Import-Csv "C:\Path\To\users.csv"
# Get the license SKU
$license = Get-MgSubscribedSku | Where-Object { $_.SkuPartNumber -eq "ENTERPRISEPACK" }
foreach ($user in $users) {
try {
$userId = (Get-MgUser -UserId $user.UserPrincipalName).Id
Set-MgUserLicense -UserId $userId `
-AddLicenses @(@{SkuId = $license.SkuId}) `
-RemoveLicenses @()
Write-Host "âś… License assigned to $($user.UserPrincipalName)"
}
catch {
Write-Warning "⚠️ Failed for $($user.UserPrincipalName): $_"
}
}
📝 To find the available SkuPartNumber values in your tenant, run:
Get-MgSubscribedSku | Select-Object SkuId, SkuPartNumber
Error | Cause | Solution |
User not found | Incorrect UPN in the CSV | Ensure the UserPrincipalName matches exactly |
Access denied | Missing Graph permission scopes | Connect with User.ReadWrite.All and Directory.ReadWrite.All |
License assignment failed | SKU not available or out of licenses | Check with Get-MgSubscribedSku and verify seat availability |
This script greatly simplifies the process of assigning licenses to multiple users. Instead of manually assigning licenses in the admin portal, you can now handle bulk assignments with one script and a properly formatted CSV file.
Ideal for onboarding scenarios or tenant-wide license transitions, this Graph PowerShell approach reduces manual overhead and brings consistency to your license management process.
© m365corner.com. All Rights Reserved. Design by HTML Codex