Open skellyatsnhu opened 8 months ago
Just confirming that I've replicated your issue, and tried a few different things as well (null, $null, 'null', "'null'", '$null', `$null)
I've been able to successfully set this via Graph Explorer, so it does appear to be an issue with the SDK:
It seems to need an unquoted value for null, where the values for Minor, NotAdult, and Adult need quotes around them. i.e. Correct: null Incorrect: "null"
Correct: "Minor", "NonAdult", "Adult" Incorrect: Minor, NonAdult, Adult
It appears as though the SDK is automatically adding quotes around the null (debug below):
Unfortunately, this problem has been known for some years (see this issue from 2017 on the AzureAD Powershell repo)
You were right to use Invoke-GraphRequest as it is the suggested workaround. The command that you're looking for would be : Invoke-GraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/users/$myupn" -Body '{"AgeGroup": null}'
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
Is your feature request related to a problem? Please describe. No
Describe the solution you'd like The Update-MgUser documentation states that -AgeGroup accepts
null
as one of its values. In practice, it does not, erroring out. What does work isadult
,minor
, andnotadult
.Describe alternatives you've considered
update-mguser -userid "somebody@domain.com" -agegroup null
update-mguser -userid "somebody@domain.com" -agegroup "null"
update-mguser -userid "somebody@domain.com" -agegroup $null
Invoke-GraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/Users/$($myupn)" -Body '{"AgeGroup": []}'
^This also fails with effectively the same error.Additional context n/a