-
Notifications
You must be signed in to change notification settings - Fork 190
Set-MgBetaUserLicense not working #3201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
also fails with Set-MgUserLicense Set-MgUserLicense -UserId $User.Id -AddLicenses @{} -RemoveLicenses @($CopilotSKUId) -debug Are you sure you want to perform this action? HTTP Method: Absolute Uri: Headers: Body: DEBUG: ============================ HTTP RESPONSE ============================ Status Code: Headers: Body: |
Same issue for me with Set-MgUserLicense. I thought I was losing my mind. Glad I found I am not the only one. |
Same here trying with Set-MgUserLicense. I even tried two different versions of powershell: 7.5 and 5.1. Nothing |
Same here with "Set-MgBetaUserLicense".
This error is happening on a script which as been working for months without issue, up until today. Steps taken:
"Connect-MgGraph -Scopes "User.ReadWrite.All", "Group.ReadWrite.All", "Organization.Read.All"" The issue persists after taking the above steps. I'm setting licenses manually for the time being. |
Same issue here. Tryed to downgrade all modules , same issue. issue could be to api callee? |
Same issue here |
Same problem here, previous version I had installed had no problems. Literally Just updated, then found myself here with the same problem. |
Running into the same issue. Downgrading does not resolve either. |
Downtrade to: 2.24, mine is working again on this version. Uninstall all graph modules then Install-Module -Name Microsoft.Graph -RequiredVersion 2.24.0 |
Invoke-MgGraphRequest POST "v1.0/users/$userUPN/assignLicense" -Body @{ That is the ONLY thing that worked for me today! I do have already remove ALL Ms-Graph and now, I did reinstall 2.26.1 |
This worked for me! I used this script (https://blog.icewolf.ch/archive/2022/03/18/cleanup-microsoft-graph-powershell-modules/ #) and changed the last line to Install-Module -Name Microsoft.Graph -RequiredVersion 2.24.0 @magoogle Thanks a ton! |
Thanks @jmartelgit i finally choose this way that's give me the possibility to keep last release of module. |
You can also do > Set-MgUserLicense -UserId $upn -BodyParameter @{addLicenses = @(); removeLicenses = @($skuID)} |
@salbeck-sit , the set command is not working anymore.. that is the purpose of this long thread ;) |
I hope this helps:
|
@PSNobbi , yes! i did wrote exactly the same above! removeLicenses$EmsSku = Get-MgBetaSubscribedSku | Where SkuPartNumber -eq 'EMSPREMIUM' |
@timayabi2020 Why does Microsoft not have unit tests in place for these cmdlets that must pass prior to release? This never should have been released with the cmdlet being completely non-functional due to this bug. Sure, I can use Invoke-MgGraphRequest to work around the bug, but the whole point of Graph PowerShell existing is so that scripts can be built without needing to do that, and releases need to not break past functionality. |
There still has not been a new version pushed and this is still broken. |
The latest module has been released. However, even with the latest version, I get an error when I run "Set-MgUserLicense -UserId $userUPN -AddLicenses @{SkuId = ""} -RemoveLicenses @()". |
Upgrading to 2.27.0 does fix it for me, the command is working normally again. |
Not fixed for me |
Describe the bug
The cmdlet:
gives error:
This code was working in the past.
Expected behavior
It should be possible to assing just a license without removing one. This has be done in the past by adding an empty array in the RemoveLicenses parameter like documented.
How to reproduce
Try to assign a license without removing one.
SDK Version
ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Script 2.26.1 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext…} Script 2.26.1 Microsoft.Graph.Beta.Applications {Add-MgBetaApplicationKey, Add-MgBetaApplicationPassword, Add-MgBetaServicePrincipalTokenSigni… Script 2.26.1 Microsoft.Graph.Beta.Groups {Add-MgBetaGroupFavorite, Add-MgBetaGroupSiteContentModelGetByNameToDrive, Add-MgBetaGroupToLi… Script 2.26.1 Microsoft.Graph.Beta.Identity.Dire… {Complete-MgBetaDirectoryImpactedResource, Complete-MgBetaDirectoryRecommendation, Complete-Mg… Script 2.26.1 Microsoft.Graph.Beta.Identity.Gove… {Add-MgBetaAccessReviewDecision, Add-MgBetaAccessReviewInstanceDecision, Add-MgBetaIdentityGov… Script 2.26.1 Microsoft.Graph.Beta.Identity.Sign… {Confirm-MgBetaInformationProtectionSignature, Confirm-MgBetaRiskyServicePrincipalCompromised,… Script 2.26.1 Microsoft.Graph.Beta.Users {Complete-MgBetaUserOutlookTask, Complete-MgBetaUserOutlookTaskFolderTask, Complete-MgBetaUser… Script 2.26.1 Microsoft.Graph.Beta.Users.Actions {Clear-MgBetaUserAndBlockManagedApp, Clear-MgBetaUserManagedAppRegistrationByAzureAdDeviceId, …
Latest version known to work for scenario above?
2.25.X
Known Workarounds
Downgrading module could work may does not have to
Debug output
Click to expand log
```DEBUG: [CmdletBeginProcessing]: - Set-MgBetaUserLicense begin processing with parameterSet 'AssignExpanded'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [Application.ReadWrite.All, AppRoleAssignment.ReadWrite.All, AuditLog.Read.All, ChannelMessage.Send, Contacts.Read, CrossTenantInformation.ReadBasic.All, DelegatedPermissionGrant.ReadWrite.All, DeviceManagementApps.Read.All, DeviceManagementApps.ReadWrite.All, DeviceManagementConfiguration.Read.All, DeviceManagementConfiguration.ReadWrite.All, DeviceManagementManagedDevices.Read.All, DeviceManagementManagedDevices.ReadWrite.All, DeviceManagementRBAC.Read.All, DeviceManagementServiceConfig.Read.All, DeviceManagementServiceConfig.ReadWrite.All, Directory.AccessAsUser.All, Directory.Read.All, Directory.ReadWrite.All, Domain.ReadWrite.All, email, Group.ReadWrite.All, GroupMember.ReadWrite.All, openid, Organization.ReadWrite.All, OrganizationalBranding.ReadWrite.All, Policy.Read.All, Policy.ReadWrite.AuthenticationMethod, Policy.ReadWrite.Authorization, Policy.ReadWrite.ConditionalAccess, Policy.ReadWrite.CrossTenantAccess, Policy.ReadWrite.DeviceConfiguration, Policy.ReadWrite.PermissionGrant, profile, RoleAssignmentSchedule.ReadWrite.Directory, RoleEligibilitySchedule.Read.Directory, RoleEligibilitySchedule.ReadWrite.Directory, RoleManagement.Read.All, RoleManagement.ReadWrite.Directory, SharePointTenantSettings.ReadWrite.All, TeamMember.ReadWrite.All, TeamsApp.ReadWrite.All, TeamsAppInstallation.ReadWriteForTeam, TeamsAppInstallation.ReadWriteSelfForTeam, TeamSettings.ReadWrite.All, TeamsTab.ReadWrite.All, User.Read.All, User.ReadWrite.All, UserAuthenticationMethod.Read.All, UserAuthenticationMethod.ReadWrite.All, WindowsUpdates.ReadWrite.All].
Confirm
Are you sure you want to perform this action?
Performing the operation "Set-MgBetaUserLicense_AssignExpanded" on target "Call remote 'POST /users/{user-id}/microsoft.graph.assignLicense' operation".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): A
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://graph.microsoft.com/beta/users/0e88beff-7c45-4bc2-9631-bca7e7e0908b/microsoft.graph.assignLicense
Headers:
FeatureFlag : 00000003
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.26100; de-CH),PowerShell/2025.0.0
SdkVersion : graph-powershell-beta/2.26.1
client-request-id : fb641a05-b41d-4fb6-ab26-24d6bb4974d9
Accept-Encoding : gzip,deflate,br
Body:
{
"addLicenses": [
{
"skuId": "f245ecc8-75af-4f8e-b61f-27d8114de5f3"
}
]
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Cache-Control : no-cache
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 974af0e7-9da6-49f6-83e8-c257c2b9a881
client-request-id : fb641a05-b41d-4fb6-ab26-24d6bb4974d9
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Switzerland North","Slice":"E","Ring":"3","ScaleUnit":"000","RoleInstance":"ZR1PEPF0000066C"}}
Link : https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,Users&from=2022-02-01&to=2022-03-01;rel="deprecation";type="text/html"
deprecation : Thu, 17 Feb 2022 23:59:59 GMT
sunset : Sat, 17 Feb 2024 23:59:59 GMT
x-ms-resource-unit : 1
Date : Fri, 28 Feb 2025 20:06:39 GMT
Body:
{
"error": {
"code": "Request_BadRequest",
"message": "One or more parameters of the operation 'assignLicense' are missing from the request payload. The missing parameters are: removeLicenses.",
"innerError": {
"date": "2025-02-28T20:06:39",
"request-id": "974af0e7-9da6-49f6-83e8-c257c2b9a881",
"client-request-id": "fb641a05-b41d-4fb6-ab26-24d6bb4974d9"
}
}
}
Set-MgBetaUserLicense_AssignExpanded: D:\Repos\PFIBDO-ADM-CloudConfiguration\scripts\aad\Configure-Licenses.ps1:261:25
Line |
261 | … Set-MgBetaUserLicense -UserId $adUser.Id -AddLicenses @(@ …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| One or more parameters of the operation 'assignLicense' are missing from the request payload. The missing parameters are: removeLicenses. Status: 400
| (BadRequest) ErrorCode: Request_BadRequest Date: 2025-02-28T20:06:39 Headers: Cache-Control : no-cache Vary :
| Accept-Encoding Strict-Transport-Security : max-age=31536000 request-id : 974af0e7-9da6-49f6-83e8-c257c2b9a881 client-request-id
| : fb641a05-b41d-4fb6-ab26-24d6bb4974d9 x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Switzerland
| North","Slice":"E","Ring":"3","ScaleUnit":"000","RoleInstance":"ZR1PEPF0000066C"}} Link :
| https://developer.microsoft-tst.com/en-us/graph/changes?$filterby=beta,Users&from=2022-02-01&to=2022-03-01;rel="deprecation";type="text/html" deprecation
| : Thu, 17 Feb 2022 23:59:59 GMT sunset : Sat, 17 Feb 2024 23:59:59 GMT x-ms-resource-unit : 1 Date
| : Fri, 28 Feb 2025 20:06:39 GMT
Recommendation: See service error codes: https://learn.microsoft.com/graph/errors
The text was updated successfully, but these errors were encountered: