Hello,
I am attempting to update device category in Intune through Microsoft Graph PowerShell, specifically the Beta, and I am encountering the issue below.
I am "successfully" updating the device categories when using command below but it does not change anything in Microsoft Intune.
Update-MgBetaDevice -DeviceId "Id" -DeviceCategory "String"
I am therefore attempting to change it to using the command below instead but I am encountering that it does not accept a string like the previous command.
Update-MgBetaDeviceManagementManagedDevice -ManagedDeviceId "Id" -DeviceCategory "String"Update-MgBetaDeviceManagementManagedDevice: Cannot process argument transformation on parameter 'DeviceCategory'.
Cannot convert the "String" value of type "System.String" to type "Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphDeviceCategory".
I am then attempting to change it to send it a Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphDeviceCategory type of property instead and I encounter this new error.
Update-MgBetaDeviceManagementManagedDevice -ManagedDeviceId Id -DeviceCategory (Get-MgBetaDeviceManagementDeviceCategory -Filter "Displayname eq 'String'") -Debug
DEBUG: [CmdletBeginProcessing]: - Update-MgBetaDeviceManagementManagedDevice begin processing with parameterSet 'UpdateExpanded'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [Device.ReadWrite.All, DeviceManagementConfiguration.Read.All, DeviceManagementConfiguration.ReadWrite.All, DeviceManagementManagedDevices.PrivilegedOperations.All, DeviceManagementManagedDevices.ReadWrite.All, Directory.AccessAsUser.All, Directory.Read.All, Directory.ReadWrite.All, Group.ReadWrite.All, openid, profile, User.Read, User.Read.All, email].
Confirm
Are you sure you want to perform this action?
Performing the operation "Update-MgBetaDeviceManagementManagedDevice_UpdateExpanded" on target "Call remote 'PATCH /deviceManagement/managedDevices/{managedDevice-id}' operation".
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
PATCH
Absolute Uri:
https://graph.microsoft.com/beta/deviceManagement/managedDevices/Id
Headers:
FeatureFlag : 00000043
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22621; en-SE),PowerShell/2023.8.0
Accept-Encoding : gzip
SdkVersion : graph-powershell-beta/2.5.0
client-request-id : d97edf60-84c0-4b5f-8e9b-a53557e56ee9
Body:
{
"deviceCategory": {
"id": "Id",
"displayName": "String",
"roleScopeTagIds": [
"0"
]
}
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 5f48ea6f-95b3-4000-802a-39a3dbd77cc4
client-request-id : d97edf60-84c0-4b5f-8e9b-a53557e56ee9
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Sweden Central","Slice":"E","Ring":"5","ScaleUnit":"001","RoleInstance":"GV2PEPF00000EA8"}}
Date : Thu, 12 Oct 2023 11:29:55 GMT
Body:
{
"error": {
"code": "ModelValidationFailure",
"message": "The property 'roleScopeTagIds' does not exist on type 'microsoft.management.services.api.deviceCategory'. Make sure to only use property names that are defined by the type.",
"innerError": {
"message": "The property 'roleScopeTagIds' does not exist on type 'microsoft.management.services.api.deviceCategory'. Make sure to only use property names that are defined by the type.",
"date": "2023-10-12T11:29:55",
"request-id": "5f48ea6f-95b3-4000-802a-39a3dbd77cc4",
"client-request-id": "d97edf60-84c0-4b5f-8e9b-a53557e56ee9"
}
}
}
Update-MgBetaDeviceManagementManagedDevice_UpdateExpanded: The property 'roleScopeTagIds' does not exist on type 'microsoft.management.services.api.deviceCategory'. Make sure to only use property names that are defined by the type.
Status: 400 (BadRequest)
ErrorCode: ModelValidationFailure
Date: 2023-10-12T11:29:55
Headers:
Transfer-Encoding : chunked
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : 5f48ea6f-95b3-4000-802a-39a3dbd77cc4
client-request-id : d97edf60-84c0-4b5f-8e9b-a53557e56ee9
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"Sweden Central","Slice":"E","Ring":"5","ScaleUnit":"001","RoleInstance":"GV2PEPF00000EA8"}}
Date : Thu, 12 Oct 2023 11:29:55 GMT
DEBUG: [CmdletEndProcessing]: - Update-MgBetaDeviceManagementManagedDevice end processing.
I attempted to exclude the RoleScopeTagIds property but it complains anyway.
Update-MgBetaDeviceManagementManagedDevice -ManagedDeviceId Id -DeviceCategory (Get-MgBetaDeviceManagementDeviceCategory -Filter "Displayname eq 'String'" | Select-Object -ExcludeProperty RoleScopeIds)
Update-MgBetaDeviceManagementManagedDevice: Cannot process argument transformation on parameter 'DeviceCategory'. Cannot convert the "@{Description=; DisplayName=String; Id=Id; RoleScopeTagIds=System.String[]; AdditionalProperties=System.Collections.Generic.Dictionary`2[System.String,System.Object]}" value of type "Selected.Microsoft.Graph.Beta.PowerShell.Models.MicrosoftGraphDeviceCategory" to type "Microsoft.Graph.Beta.PowerShell.Models.IMicrosoftGraphDeviceCategory".
Thoughts? I am stuck.