microsoftgraph / microsoftgraph/msgraph-sdk-powershell
Update-MgDeviceManagementManagedDeviceCategory does not update the device category as intended for Intune managed devices
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 898
- Forks
- 230
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 31
Description
Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:
- Make sure you can reproduce this issue using the latest released version of Microsoft.Graph or Microsoft.Graph.Beta.
- Please search the existing issues to see if there has been a similar issue filed.
- For issues related to authentication and service errors, please refer to our troubleshooting guide. For service issues, please open a question at https://developer.microsoft.com/graph/support.
Describe the bug
Aim: Update device category of Intune managed devices via the Microsoft.Graph.DeviceManagement library using PowerShell.
I found the following cmdlet: Update-MgDeviceManagementManagedDevicesCategory which should (in theory) update the device category. Firstly, I verified that the correct device details are showing up using the cmdlet: Get-MgDeviceManagementManagedDeviceCategory -managedDeviceId <Intune device Id>. This worked and returned the following output.
However, when I use the Update command, it fails with error "No OData route exists."
Command executed: Update-MgDeviceManagementManagedDeviceCategory -managedDeviceId <Intune device Id> -DisplayName "Contoso"
Output:
Update-MgDeviceManagementManagedDeviceCategory : No OData route exists that match template
~/singleton/navigation/key/navigation with http verb PATCH for request /DeviceFE/StatelessDeviceFEService/deviceManagem
ent/managedDevices('fd7c3a2b-4c26-448d-9498-4770a84a176b')/deviceCategory.
Status: 400 (BadRequest)
ErrorCode: No method match route template
Date: 2023-11-20T09:46:38
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id :
client-request-id :
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"South
India","Slice":"E","Ring":"2","ScaleUnit":"001","RoleInstance":"MA1PEPF0000272F"}}
Date : Mon, 20 Nov 2023 09:46:38 GMT
At line:1 char:1
- Update-MgDeviceManagementManagedDeviceCategory -managedDeviceId fd7c3 ...
-
+ CategoryInfo : InvalidOperation: ({ ManagedDevice...eviceCategory }:<>f__AnonymousType90`2) [Update-MgD evice..._UpdateExpanded], Exception + FullyQualifiedErrorId : No method match route template,Microsoft.Graph.PowerShell.Cmdlets.UpdateMgDeviceManageme ntManagedDeviceCategory_UpdateExpanded
Running the Graph query /deviceManagement/managedDevices('fd7c3a2b-4c26-448d-9498-4770a84a176b')/deviceCategory in Graph Explorer returns successful result.
To Reproduce
Steps to reproduce the behavior:
- Connect to Graph API. Execute
Connect-MgGraph - Execute
Update-MgDeviceManagementManagedDeviceCategory -managedDeviceId <Intune device Id> -DisplayName "<Category name>"
Expected behavior
As per documentation, we should be able to update the device category display name.
Debug Output
DEBUG: [CmdletBeginProcessing]: - Update-MgDeviceManagementManagedDeviceCategory begin processing with parameterSet
'UpdateExpanded'.
Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope:
'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [Device.ReadWrite.All, DeviceManagementManagedDevices.Read.All,
DeviceManagementManagedDevices.ReadWrite.All, DeviceManagementServiceConfig.ReadWrite.All, Group.ReadWrite.All, openid,
profile, User.Read, email].
Confirm
Are you sure you want to perform this action?
Performing the operation "Update-MgDeviceManagementManagedDeviceCategory_UpdateExpanded" on target "Call remote 'PATCH
/deviceManagement/managedDevices/{managedDevice-id}/deviceCategory' operation".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): a
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
PATCH
Absolute Uri:
https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/fd7c3a2b-4c26-448d-9498-4770a84a176b/deviceCategory
Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22631;
en-US),PowerShell/5.1.22621.2506
Accept-Encoding : gzip
SdkVersion : graph-powershell/2.9.0
client-request-id : <redacted>
Body:
{
"displayName": "Contoso"
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : <redacted>
client-request-id : <redacted>
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"South
India","Slice":"E","Ring":"2","ScaleUnit":"000","RoleInstance":"MA1PEPF000012F3"}}
Date : Mon, 20 Nov 2023 09:59:32 GMT
Body:
{
"error": {
"code": "No method match route template",
"message": "No OData route exists that match template ~/singleton/navigation/key/navigation with http verb PATCH
for request
/DeviceFE/StatelessDeviceFEService/deviceManagement/managedDevices('fd7c3a2b-4c26-448d-9498-4770a84a176b')/deviceCatego
ry.",
"innerError": {
"date": "2023-11-20T09:59:32",
"request-id": "<redacted>",
"client-request-id": "<redacted>"
}
}
}
Confirm
No OData route exists that match template ~/singleton/navigation/key/navigation with http verb PATCH for request
/DeviceFE/StatelessDeviceFEService/deviceManagement/managedDevices('fd7c3a2b-4c26-448d-9498-4770a84a176b')/deviceCatego
ry.
Status: 400 (BadRequest)
ErrorCode: No method match route template
Date: 2023-11-20T09:59:32
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : <redacted>
client-request-id : <redacted>
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"South
India","Slice":"E","Ring":"2","ScaleUnit":"000","RoleInstance":"MA1PEPF000012F3"}}
Date : Mon, 20 Nov 2023 09:59:32 GMT
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
Update-MgDeviceManagementManagedDeviceCategory : No OData route exists that match template
~/singleton/navigation/key/navigation with http verb PATCH for request /DeviceFE/StatelessDeviceFEService/deviceManagem
ent/managedDevices('fd7c3a2b-4c26-448d-9498-4770a84a176b')/deviceCategory.
Status: 400 (BadRequest)
ErrorCode: No method match route template
Date: 2023-11-20T09:59:32
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : <redacted>
client-request-id : <redacted>
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"South
India","Slice":"E","Ring":"2","ScaleUnit":"000","RoleInstance":"MA1PEPF000012F3"}}
Date : Mon, 20 Nov 2023 09:59:32 GMT
At line:1 char:1
+ Update-MgDeviceManagementManagedDeviceCategory -managedDeviceId fd7c3 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ ManagedDevice...eviceCategory }:<>f__AnonymousType90`2) [Update-MgD
evice..._UpdateExpanded], Exception
+ FullyQualifiedErrorId : No method match route template,Microsoft.Graph.PowerShell.Cmdlets.UpdateMgDeviceManageme
ntManagedDeviceCategory_UpdateExpanded
DEBUG: [CmdletEndProcessing]: - Update-MgDeviceManagementManagedDeviceCategory end processing.
Module Version
Script 2.9.0 Microsoft.Graph.Authentication
Script 2.9.0 Microsoft.Graph.DeviceManagement
Environment Data
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Discussed internally with Microsoft SME (markstan) and he confirmed that this needs to be reported on why the command fails with error "No OData route exists" when the same can be queried with Graph explorer or by using the invoke commands.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the PATCH request from Update-MgDeviceManagementManagedDeviceCategory and compare it with the successful Graph Explorer query for the deviceCategory endpoint. The issue names no repository files or tests, so determine whether the generated cmdlet or the Microsoft Graph route is responsible; done means the documented update command succeeds or the mismatch is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100