microsoftgraph / microsoftgraph/msgraph-sdk-powershell

Update-MgDeviceManagementManagedDevice fails to update device category of Intune managed devices

Offen
#2,452 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

type:bug
Vorherrschende Sprache
C#
Sterne
898
Forks
230
Ø Merge
2 T. 5 Std.
Gemergte PRs (30 T.)
31

Beschreibung

Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:

Describe the bug

A clear and concise description of what the bug is.

Aim: Update device category of Intune managed devices via the Microsoft.Graph.DeviceManagement library using PowerShell.

I found the following cmdlet: Get-MgDeviceManagementManagedDevice with deviceCategory parameter which should (in theory) update the device category.

PowerShell script used.

Connect-MgGraph

function Update-DeviceCategory {
  param (
    [Parameter (Mandatory)]
    [string]$DeviceID,
    [Parameter (Mandatory)]
    [string]$DeviceCategory
  )
  Write-Host "Updating device category: $DeviceCategory, for device: $DeviceID"
  $body = @{
    '@odata.id' = "https://graph.microsoft.com/beta/deviceManagement/deviceCategories/$DeviceCategory"
  }
  Update-MgDeviceManagementManagedDevice -managedDeviceId $DeviceID -BodyParameter $body -debug
}

$intuneDevice = Get-MgDeviceManagementManagedDevice -managedDeviceId "fd7c3a2b-4c26-448d-9498-4770a84a176b"
$deviceCategory = '5b1d64fa-506c-48c8-b933-99533ffcd352'

Update-DeviceCategory -DeviceID $intuneDevice.id -DeviceCategory $deviceCategory

Output: The script runs without errors and it seems like it completed successfully as seen below.

image

However, the device category never updates as confirmed via Graph explorer.

image

Furthermore, from the verbose logs, we can see that the body of the response being sent is blank.

Screenshot 2023-11-20 195232

To Reproduce
Steps to reproduce the behavior:

  1. Create a device category in Intune
  2. Run the above script with the device category ID obtained from point 1.

Expected behavior

A clear and concise description of what you expected to happen.

The device category for the device should update to the mentioned ID.

Debug Output

Run the problematic command with -Debug and paste the resulting debug stream below.
⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs.

Updating device category: 5b1d64fa-506c-48c8-b933-99533ffcd352, for device: fd7c3a2b-4c26-448d-9498-4770a84a176b
DEBUG: [CmdletBeginProcessing]: - Update-MgDeviceManagementManagedDevice begin processing with parameterSet 'Update'.

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-MgDeviceManagementManagedDevice_Update" 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"): a
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PATCH

Absolute Uri:
https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/fd7c3a2b-4c26-448d-9498-4770a84a176b

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             : 495e8d3d-d049-4f6e-a419-0011b57640ed

Body:
{
  "@odata.id":
"https://graph.microsoft.com/beta/deviceManagement/deviceCategories/5b1d64fa-506c-48c8-b933-99533ffcd352"
}

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
NoContent

Headers:
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":"002","RoleInstance":"MA1PEPF00003153"}}
Date                          : Mon, 20 Nov 2023 14:21:28 GMT

Body:

DEBUG: [CmdletEndProcessing]: - Update-MgDeviceManagementManagedDevice end processing.

Module Version

Please run Get-Module Microsoft.Graph* after cmdlet execution and paste the output below.
If a module cannot be installed or imported, please run Get-Module -ListAvailable and paste the output.

Script 2.9.0 Microsoft.Graph.Authentication
Script 2.9.0 Microsoft.Graph.DeviceManagement

Environment Data

Please run $PSVersionTable and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine.

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.

Added above where applicable.

Additional context

Add any other context about the problem here.

Related to another issue I posted.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem Cmdlet Update-MgDeviceManagementManagedDevice und reproduziere die in der Debug-Ausgabe gezeigte PATCH-Anforderung unter Verwendung der bereitgestellten Geräte- und Kategorie-IDs. Vergleiche die Anforderung mit dem zugehörigen Issue und dem Verhalten von Microsoft Graph; die Arbeit ist abgeschlossen, wenn die Gerätekategorie erfolgreich geändert wurde und das Ergebnis über Graph Explorer verifiziert werden kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell
Bereich
api, tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.