microsoftgraph / microsoftgraph/msgraph-sdk-powershell

[Support Setting Fields to null] Unable to set BusinessPhones or MobilePhone fields to $null

Open
#833 18 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

AutoREST-dependency Blocked Request: Feature Request: Kiota
Dominant language
C#
Stars
898
Forks
230
Avg merge
2d 5h
Merged PRs (30d)
31

Description

Hi,

When trying to set BusinessPhones or MobilePhone values to $null, like so:
Update-MgUser -UserId $MgUser.UserPrincipalName -MobilePhone $null -BusinessPhones $null

It throws an error:
Update-MgUser_UpdateExpanded: Invalid value specified for property 'mobilePhone' of resource 'User'.

I've fixed this for now by using an alternative command:
Invoke-GraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/Users/$($MgUser.UserPrincipalName)" -Body '{"businessPhones": [],"mobilePhone": null}'

Hope this helps someone else in a similar need and more so, the Update-MgUser cmdlet is fixed.

Thanks,
AB#10944

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Update-MgUser command with $null for MobilePhone and BusinessPhones, then compare its behavior with the provided Invoke-GraphRequest PATCH workaround. Done means Update-MgUser accepts these null values and sends the equivalent update without the invalid-property error.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.