microsoft / Intune-PowerShell-SDK

Native PowerShell support for invoking Microsoft Intune Graph API to enable IT Pro scenario automation.
MIT License
314 stars 77 forks source link

"Update-IntuneManagedDevice" fails with "400 Bad Request" #107

Closed CloudViking86 closed 3 years ago

CloudViking86 commented 3 years ago

PowerShell: 5.1 MSGraphEnvironment set to "beta" MS.Graph.Intune-module: v. 6.1907.1.0

Command: Update-IntuneManagedDevice -managedDeviceId $($entry_device.id) -userPrincipalName $intune_adduserprompt_prompt_userid

Where "$($entry_device.id)" is the "id" of an Intune managed device and "$intune_adduserprompt_prompt_userid" is a "Read-Host" where the user enters a UPN such as "my.user@mydomain.com" to assign a primary user to an orphaned device missing a primary user (such as when it is enrolled by a provisioning package).

Result: Update-IntuneManagedDevice : 400 Bad Request { "error": { "code": "InternalError", "message": "{\r\n \"_version\": 3,\r\n \"Message\": \"An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: <redacted> - Url: https://fef.msub05.manage.microsof t.com/DeviceFE/StatelessDeviceFEService/deviceManagement/managedDevices%28%<device-id-of-intune-device-redacted>%27%29?api-versio n=5021-03-03\",\r\n \"CustomApiErrorPhrase\": \"\",\r\n \"RetryAfter\": null,\r\n \"ErrorSourceService\": \"\",\r\n \"HttpHeaders\": \"{}\"\r\n}", "innerError": { "date": "2021-04-16T07:52:29", "request-id": <redacted> "client-request-id": <redacted> } } }

Expected result: Assigns / updates "userPrincipalName" on the targeted "managedDeviceId "

Possible clone of / related to: https://github.com/microsoft/Intune-PowerShell-SDK/issues/102

CloudViking86 commented 3 years ago

Closing this since you should apparently use "microsoftgraph/msgraph-sdk-powershell" so for example the command: "Update-MgDeviceManagementManagedDevice" which is included there.