msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

Invoke-MgGraphRequest no longer allowing OnPremisesImmutableId to be nulled

Open ThatOneHorse opened this issue 1 year ago • 0 comments

Describe the bug

Performing "Invoke-MgGraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/Users/[user id]" -Body @{OnPremisesImmutableId = $null}" returns a 400, Bad Request currently

Expected behavior

As recently as last week I was able to utilize this line which has been provided as a workaround for Update-MgUser not supporting nulling the ImmutableId in Entra.

How to reproduce

  1. Import modules Microsoft.Graph.Users and Microsoft.Graph.Identity.DirectoryManagement
  2. Connect-MgGraph with scopes User.ReadWrite.All, Domain.ReadWrite.All, Directory.AccessAsUser.All
  3. Execute Invoke-MgGraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/Users/[user id]" -Body @{OnPremisesImmutableId = $null}

SDK Version

2.19.0

Latest version known to work for scenario above?

No response

Known Workarounds

Technically, the line I'm running is the workaround.

Debug output

Click to expand log ```

DEBUG: PATCH /v1.0/Users/[user id] HTTP/1.1 HTTP: graph.microsoft.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.22635; en-US) PowerShell/2024.2.2 Invoke-MgGraphRequest
Content-Length: 30 Content-Type: application/json

{"OnPremisesImmutableId":null} VERBOSE: received 259-byte response of content type application/json

DEBUG: PATCH https://graph.microsoft.com/v1.0/Users/[user id] HTTP/2.0 400 Bad Request Cache-Control: no-cache Vary: Accept-Encoding Strict-Transport-Security: max-age=31536000 request-id: 2846713c-f008-49b3-b4f6-ea30064b5037 client-request-id: 40294d1e-c4bc-4045-b09f-ce7c1f9f4fe2 x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"003","RoleInstance":"SN4PEPF000004FB"}} x-ms-resource-unit: 1 Date: Fri, 28 Jun 2024 16:22:36 GMT Content-Type: application/json Content-Encoding: gzip

{"error":{"code":"Request_BadRequest","message":"Property value is required but is empty or missing.","innerError":{"date":"2024-06-28T16:22:36","request-id":"2846713c-f008-49b3-b4f6-ea30064b5037","client-request-id":"40294d1e-c4bc-4045-b09f-ce7c1f9f4fe2"}}}

</details>


### Configuration

PSVersion                      7.4.3
PSEdition                      Core
GitCommitId                    7.4.3
OS                             Microsoft Windows 10.0.22635
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

### Other information

It appears that the request is not actually passing $null as a valid property per the debug output, but I'm not well-versed enough to speculate further.

Also, I can reproduce this in the Graph Explorer.

ThatOneHorse avatar Jun 28 '24 16:06 ThatOneHorse