Many people reported the same issue. Also, few more issues also reported in MS Graph PowerShell V2.26. You can downgrade to 2.25. (Uninstall latest module and install the MS Graph PowerShell module with -RequiredVersion param).
Set-MgUserLicense broken?
in ps 7.5, Microsoft.Graph.Users.Actions 2.26.1
Set-MgUserLicense -UserId $script:userEmail -AddLicenses @(@{skuId=$skuId}) -RemoveLicenses @()
Fails with message:
One or more parameters of the operation 'assignLicense' are missing from the request payload. The missing parameters are: removeLicenses.
The same happens if -AddLicenses
is @()
The only thing working is if you simultaneously add and remove licenses. (Both Fields being non-empty arrays).
The documentation clearly states empty arrays as use case. Could you confirm this is a bug?
Microsoft Security | Microsoft Graph
3 answers
Sort by: Most helpful
-
-
cedric monnet 0 Reputation points
2025-03-06T14:21:50.2633333+00:00 thread here, https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3201 even if you downgrade the module, the issue still here. Waiting a correction to the api but it's really painfull to do it through the portal...
We will end up complaining about not being able to manage our licensing costs in an industrial way
-
Jehan Snyers d'Attenhoven 0 Reputation points
2025-03-27T11:35:12.14+00:00 This is really a pain as there is currently no easy way (and no other way) to remove directly assigned licenses since they have moved licenses management solely to the M365 Admin Center and no more in Entra.
At the moment, you must direct POST command to overcome the issue.
removeLicenses
$EmsSku = Get-MgBetaSubscribedSku | Where SkuPartNumber -eq 'EMSPREMIUM' $userId = (Get-MgBetaUser -UserId ******@XXXXXXXXXX.com).Id $body = @{ "addLicenses" = @() "removeLicenses" = @($EmsSku.SkuId) } Invoke-MgGraphRequest POST "v1.0/users/$userId/assignLicense" -Body $body