Skip to content

Set-MgUserLicense optimizes out necessary empty parameters #3273

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

Closed
dt-flo opened this issue Apr 15, 2025 · 2 comments
Closed

Set-MgUserLicense optimizes out necessary empty parameters #3273

dt-flo opened this issue Apr 15, 2025 · 2 comments
Labels
status:duplicate A duplicate issue

Comments

@dt-flo
Copy link

dt-flo commented Apr 15, 2025

Describe the bug

I hope the titel is alright, please tell me if I should change it if it is unclear.
When running the command Set-MgUserLicense -UserId "great@account.com" -RemoveLicenses @("b70a4eeb-32f6-4c99-af47-3c822a4bbc59") -AddLicenses @() as described for example in Example 6 in the MS docs, the Graph SDK detects that -AddLicenses @() is essentially empty and omits it from the HTTP request. However, the Microsoft Graph API requires that AddLicenses is present even though it is empty. The same behavior can be reproduced with RemoveLicenses

Example:
Set-MgUserLicense -UserId "great@account.com" -RemoveLicenses @() -AddLicenses @() -Debug results in

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://graph.microsoft.com/v1.0/users/REDACTED/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-DE),PowerShell/7.5.0
SdkVersion                    : graph-powershell/2.26.1
client-request-id             : REDACTED
Accept-Encoding               : gzip,deflate,br

Body:
{}

an empty body and therefor in the error

Set-MgUserLicense_AssignExpanded: One or more parameters of the operation 'assignLicense' are missing from the request payload. The missing parameters are: addLicenses,removeLicenses.

Status: 400 (BadRequest)
ErrorCode: Request_BadRequest
Date: 2025-04-15T10:59:24

. The command Set-MgGroupLicense has the exact same issue. I am using Graph SDK 2.26.1.

Expected behavior

The SDK should neither omit AddLicenses, nor RemoveLicenses

How to reproduce

See section "Describe the bug"

SDK Version

2.26.1

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

No response

Configuration

No response

Other information

No response

@dt-flo dt-flo added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Apr 15, 2025
@dt-flo dt-flo changed the title Set-MgUserLicense optimizes out empty parameters Set-MgUserLicense optimizes out necessary empty parameters Apr 15, 2025
@timayabi2020 timayabi2020 added status:duplicate A duplicate issue and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Apr 15, 2025
@timayabi2020
Copy link
Contributor

timayabi2020 commented Apr 15, 2025

Hi @dt-flo apologies for the inconvenience. This issue was already reported hereand the fix for it will be available by end of next week. I'll therefore close this as a duplicate

@wongcc2012
Copy link

Please provide the fix ASAP as this is a essential command for us to assign licenses. (2.26.1 have so many bugs as reported)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:duplicate A duplicate issue
Projects
None yet
Development

No branches or pull requests

3 participants