Open SamSepiolWarden opened 1 year ago
I cannot make it work either with the built-in cmdlets.
Update-MgBetaDeviceManagementManagedDevice -ManagedDeviceId $myIntuneDevice.Id -DeviceCategory $category
Update-MgBetaDeviceManagementManagedDevice : Cannot apply PATCH to navigation property 'deviceCategory' on entity type 'microsoft.management.services.api.managedDevice'.
Status: 400 (BadRequest)
ErrorCode: ModelValidationFailure
Date: 2023-10-03T17:24:51
Update-MgBetaDeviceManagementManagedDeviceCategory -ManagedDeviceId $myIntuneDevice.Id -Id $category.Id
Update-MgBetaDeviceManagementManagedDeviceCategory :
Status: 404 (NotFound)
ErrorCode: UnknownError
Date: 2023-10-03T17:03:16
The only way to make it work is like this:
$body = @{ '@odata.id' = "https://graph.microsoft.com/beta/deviceManagement/deviceCategories/$($category.Id)" }
Invoke-MgGraphRequest -Method PUT -Uri "beta/deviceManagement/managedDevices/$(myIntuneDevice.Id)/deviceCategory/`$ref" -Body $body
This one work for me :
Update-MgBetaDeviceManagementManagedDeviceCategory -ManagedDeviceId $Device -BodyParameter $BodyParams
With the new category in the body parameter
Does the cmdlet work ? because can't make work with -bodyparameter or -devicecategory, eveytime he result with an error `$Params = @{ DeviceCategory = @{ "DisplayName" = "$NewCategory"} } | ConvertTo-Json try {
Changer la category
Update-MgDeviceManagementManagedDevice -ManagedDeviceId $Device -BodyParameter $Params `