-
Notifications
You must be signed in to change notification settings - Fork 165
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
Update-MgUser - setting null values for attributes #852
Comments
The SDK does not currently support nullifying values to how the deserializer works. We will use this issue to track this as a feature request. |
Thank you for the response and using this as a feature request. |
Following. |
I'm having the same issue trying to clear the password policy for an Azure AD user through the MS Graph SDK. https://docs.microsoft.com/en-us/graph/api/user-update?view=graph-rest-1.0&tabs=http The password policy compromises two strings: DisablePasswordExpiration, DisableStrongPassword I can only remove one of the two string options at any one time by updating the user and writing over the previous configuration. It's not possible to overwite the policy with an empty string or null. This means any user who has had a password policy set previously is now stuck with at least one of the options for ever! |
FWIW, this appears to be a duplicate of #833. @gagwithgaffer You could try Invoke-GraphRequest as mentioned in that other issue. It worked for me with the City attribute. |
The workaround "Invoke-MgGraphRequest" fails on the latest module 1.14.0. You can run "Invoke-MgRestMethod" instead. |
@rui0122, please open a new issue with the repro steps and the error message. |
@yukieryu I found a workaround but I have not tested your exact situation. If you run the MG command with -bodyparameter and define your attributes in a hash table you can set "attribute" = @() and that will null it out. Let me know if that works for you as well. |
Any chance that the future SDK will finally support |
With the Set-MsolUser cmdlet, it is possible to set an attribute to "" to clear the value.
E.g. Set-MsolUser -LastName "" will clear whatever value is present for the last name.
However, Update-MgUser -UserId -Surname "" will generate error as below -
Also attempted Update-MgUser -UserId -Surname $null but the same error.
On the side note, Set-AzureADUser -objectid -Surname "" will generate an error.
https://github.com/Azure/azure-docs-powershell-azuread/issues/166
The text was updated successfully, but these errors were encountered: