Direct Inward Dialing: +1 408 916 9393
This guide covers how to replace Microsoft 365 user licenses or adjust the services inside it the Microsoft 365 admin center, the Set-MgUserLicense PowerShell cmdlet, and ManageEngine ADManager Plus.
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "User.ReadWrite.All","Organization.Read.All"
Get-MgSubscribedSku -All | Select-Object SkuPartNumber, SkuId, ConsumedUnits, @{Name="EnabledUnits"; Expression={$_.PrepaidUnits.Enabled}}
Get-MgUser -UserId "kdennis@zylker.com" -Property UserPrincipalName, UsageLocation | Select-Object UserPrincipalName, UsageLocation
Update-MgUser -UserId "kdennis@zylker.com" -UsageLocation "US"
$oldSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E3"
$newSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E5"
Set-MgUserLicense -UserId "kdennis@zylker.com" -AddLicenses @{SkuId = $newSku.SkuId} -RemoveLicenses @($oldSku.SkuId)
Get-MgUserLicenseDetail -UserId "kdennis@zylker.com" | Select-Object SkuPartNumber, SkuId
Pass DisabledPlans with the service plan IDs to switch off while the new license is assigned.
$oldSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E3"
$newSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E5"
$disabledPlans = $newSku.ServicePlans | Where-Object ServicePlanName -in ("LOCKBOX_ENTERPRISE", "MICROSOFTBOOKINGS") | Select-Object -ExpandProperty ServicePlanId
$addLicenses = @(@{SkuId = $newSku.SkuId; DisabledPlans = $disabledPlans})
Set-MgUserLicense -UserId "kdennis@zylker.com" -AddLicenses $addLicenses -RemoveLicenses @($oldSku.SkuId)
Read the plans already switched off on the user's license, add the new ones, and pass the combined list so that nothing is switched back on.
$e5Sku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E5"
$userLicense = Get-MgUserLicenseDetail -UserId "kdennis@zylker.com" | Where-Object SkuId -eq $e5Sku.SkuId
$userDisabledPlans = $userLicense.ServicePlans | Where-Object ProvisioningStatus -eq "Disabled" | Select-Object -ExpandProperty ServicePlanId
$newDisabledPlans = $e5Sku.ServicePlans | Where-Object ServicePlanName -in ("SWAY", "FORMS_PLAN_E5") | Select-Object -ExpandProperty ServicePlanId
$disabledPlans = ($userDisabledPlans + $newDisabledPlans) | Select-Object -Unique
$addLicenses = @(@{SkuId = $e5Sku.SkuId; DisabledPlans = $disabledPlans})
Set-MgUserLicense -UserId "kdennis@zylker.com" -AddLicenses $addLicenses -RemoveLicenses @()
Pass the AssignedLicenses of a reference user to give another user the same licenses.
$source = Get-MgUser -UserId "belindan@zylker.com" -Property AssignedLicenses
Set-MgUserLicense -UserId "kdennis@zylker.com" -AddLicenses $source.AssignedLicenses -RemoveLicenses @()
| Parameter | Description |
|---|---|
| -Scopes | The Microsoft Graph permission scopes to request for the session, such as User.ReadWrite.All. |
| -TenantId | The tenant to sign in to, as a tenant ID or domain name. |
| -NoWelcome | Hides the welcome banner after the connection is made. |
| Parameter | Description |
|---|---|
| -All | Returns every license plan in the tenant instead of only the first page. |
| -Property | Limits the properties returned, such as SkuPartNumber, SkuId, or ServicePlans. |
| Parameter | Description |
|---|---|
| -UserId | The object ID or user principal name of the user. |
| -Filter | An OData filter, such as assignedLicenses/any(s:s/skuId eq <SkuId>), to find users who hold a license. |
| -Property | The properties to return, such as UserPrincipalName, UsageLocation, or AssignedLicenses. |
| -All | Returns all matching users instead of only the first page. |
| Parameter | Description |
|---|---|
| -UserId | The object ID or user principal name of the user to update. |
| -UsageLocation | The two-letter ISO 3166-1 alpha-2 country code to set, such as US or FR. |
| Parameter | Description |
|---|---|
| -UserId | The object ID or user principal name of the user whose licenses change. |
| -AddLicenses | The licenses to assign, as hash tables with a SkuId and an optional DisabledPlans list. |
| -RemoveLicenses | The SkuIds of the licenses to remove. Pass @() when nothing should be removed. |
| -WhatIf | Shows what would change without making the change. |
| -Confirm | Prompts for confirmation before the change is made. |
| Parameter | Description |
|---|---|
| -UserId | The object ID or user principal name of the user whose licenses are listed. |
| -Property | Limits the properties returned, such as SkuPartNumber or ServicePlans. |
Replace all licenses removes the previous licenses of the selected users. When users hold other licenses that must stay, assign the new license first and then run Remove selected licenses for the old one.
This script finds every user who holds the old license, swaps it for the new one, and reports any user it could not change.
Connect-MgGraph -Scopes "User.ReadWrite.All","Organization.Read.All"
$oldSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E3"
$newSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E5"
$users = Get-MgUser -Filter "assignedLicenses/any(s:s/skuId eq $($oldSku.SkuId))" -All -Property Id, UserPrincipalName
if (-not $users) {
Write-Host "No users hold the license to replace."
return
}
foreach ($user in $users) {
try {
Set-MgUserLicense -UserId $user.Id -AddLicenses @{SkuId = $newSku.SkuId} -RemoveLicenses @($oldSku.SkuId) -ErrorAction Stop | Out-Null
Write-Host "Changed license for $($user.UserPrincipalName)"
} catch {
Write-Warning "Could not change license for $($user.UserPrincipalName): $($_.Exception.Message)"
}
}
If the users hold other licenses that must stay, choose Assign selected licenses in step 5 instead, and click Apply to add the new license. Then repeat step 5 with Remove selected licenses, select the old license, and click Apply.
This script finds users who hold both the old standalone license and the upgraded license, then removes the standalone one.
Connect-MgGraph -Scopes "User.ReadWrite.All","Organization.Read.All"
$redundantSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "EXCHANGEENTERPRISE"
$keepSku = Get-MgSubscribedSku -All | Where-Object SkuPartNumber -eq "SPE_E3"
$users = Get-MgUser -Filter "assignedLicenses/any(s:s/skuId eq $($redundantSku.SkuId))" -All -Property Id, UserPrincipalName, AssignedLicenses | Where-Object { $_.AssignedLicenses.SkuId -contains $keepSku.SkuId }
if (-not $users) {
Write-Host "No users hold both licenses."
return
}
foreach ($user in $users) {
try {
Set-MgUserLicense -UserId $user.Id -AddLicenses @() -RemoveLicenses @($redundantSku.SkuId) -ErrorAction Stop | Out-Null
Write-Host "Removed the redundant license from $($user.UserPrincipalName)"
} catch {
Write-Warning "Could not remove the license from $($user.UserPrincipalName): $($_.Exception.Message)"
}
}
Run Get-MgSubscribedSku -All | Select-Object SkuPartNumber, SkuId. SkuPartNumber is the readable ID, such as SPE_E5, and SkuId is the GUID that Set-MgUserLicense expects. Microsoft also publishes a list that maps product names to SKU part numbers and service plan IDs. In ADManager Plus, the License Details report lists every license in the tenant along with the services each one includes.
No. Microsoft retired the MSOnline module in 2025, so scripts that use it need to move to the Microsoft Graph PowerShell SDK. Connect-MsolService becomes Connect-MgGraph, Get-MsolUser becomes Get-MgUser, and Set-MsolUserLicense becomes Set-MgUserLicense. Licenses are now identified by the SkuId GUID instead of the AccountSkuId in the tenant:SKU form, and the DisabledPlans value in the -AddLicenses hash table replaces New-MsolLicenseOptions.
Some Microsoft 365 services are not available in every country or region, so a license can only be assigned to a user whose UsageLocation is a valid ISO 3166-1 alpha-2 country code. Set it with Update-MgUser -UsageLocation, or choose the User Location in ADManager Plus when you assign or replace licenses.
In the standard scenario, a mailbox without a hold is disconnected when its Exchange Online license is removed. Reassigning a license within 30 days reconnects it, and after 30 days the data is permanently deleted. Retention policies and holds can affect data preservation.
Yes. In PowerShell, loop through the users and call Set-MgUserLicense for each one, as shown in the use cases above. In ADManager Plus, select users by search or CSV import, or use the Group Based License Modification feature, and schedule recurring license tasks when the change should repeat.
The user has no usage location, or the value is not valid. Set it with Update-MgUser -UserId "kdennis@zylker.com" -UsageLocation "US", then run Set-MgUserLicense again.
The signed-in account does not hold a role that can assign licenses, or the session was not granted the scopes. Confirm that the account is a License Administrator or User Administrator, then reconnect with Connect-MgGraph -Scopes "User.ReadWrite.All","Organization.Read.All" and accept the consent prompt.
This error was reported with Microsoft Graph PowerShell SDK 2.26.1, which left empty -AddLicenses or -RemoveLicenses arrays out of the request. Check the installed version with Get-InstalledModule Microsoft.Graph, update it with Update-Module Microsoft.Graph, and run the command again. If the error remains, send the request with Invoke-MgGraphRequest, which the SDK maintainers suggested as a workaround.
The new license has no unassigned units left. Compare ConsumedUnits with EnabledUnits in step 3 of the PowerShell steps, then add units or free some by removing the license from users who no longer need it.
Two licenses on the user include service plans that cannot be assigned together, and Microsoft Entra ID does not resolve the conflict on its own. Turn off the overlapping plan on one of the licenses with DisabledPlans, or remove the conflicting license.
The MSOnline module was retired in 2025, so any script that calls it stops at the first Msol cmdlet. Rewrite the script with the Microsoft Graph equivalents listed in the second FAQ.