Menü Schließen

Microsoft Graph Explorer deviceManagement und Compliance Policies

Logo Microsoft

Von Zeit zu Zeit hab ich mit dem Microsoft Graph zu tun, meist um eine Auswertung per Powershell über die im Endpoint Manager vorhandenen Geräte zu bekommen. Um dies zu testen bzw. einen Überblick zu bekommen, hilft mir der Microsoft Graph Explorer. Nachfolgend ein Einstieg, der mir am Anfang recht schwer fiel. Es werden folgende Berechtigungen für das Script / die App / den User benötigt:

  • DeviceManagementConfiguration.Read.All
    Allows the app to read properties of Microsoft Intune-managed device configuration and device compliance policies and their assignment to groups.
  • DeviceManagementConfiguration.ReadWrite.All
    Allows the app to read and write properties of Microsoft Intune-managed device configuration and device compliance policies and their assignment to groups.
  1. Aufrufen der Webseite, ich nutze den Edge im Private Modus: Graph Explorer – Microsoft Graph
  2. Login mit einem berechtigten Account, welcher ggf. vorher im AzureAD berechtigt werden muss.
image

3. Als nächstes wähle ich den beta Channel und ändere die URL wie folgt ab:

Microsoft Graph Explorer Devicemanagement alle Geräte anzeigen

https://graph.microsoft.com/beta/deviceManagement/managedDevices
image 1

Achtung es werden nur die ersten 1000 Devices ausgegeben.

4. Nun auf den Button “Run query” klicken. Wenn alles stimmt, dann werden unten in der “Response preview” die Geräte im Endpoint Manager mit ihren Eigenschaften, angezeigt.

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#deviceManagement/managedDevices",
    "@odata.count": 1000,
    "@odata.nextLink": "https://graph.microsoft.com/beta/deviceManagement/managedDevices?$skiptoken=xxx",
    "value": [
        {
            "id": "xxx",
            "userId": "xxx",
            "deviceName": "xxx",
            "ownerType": "company",
            "managedDeviceOwnerType": "company",
            "managementState": "managed",
            "enrolledDateTime": "2020-05-09T09:59:22Z",
            "lastSyncDateTime": "2021-12-08T09:20:29Z",
            "chassisType": "unknown",
            "operatingSystem": "iOS",
            "deviceType": "iPhone",
            "complianceState": "compliant",
            "jailBroken": "False",
            "managementAgent": "mdm",
            "osVersion": "15.1",
            "easActivated": true,
            "easDeviceId": "xxx",
            "easActivationDateTime": "0001-01-01T00:00:00Z",
            "aadRegistered": true,
            "azureADRegistered": true,
            "deviceEnrollmentType": "appleBulkWithUser",
            "lostModeState": "disabled",
            "activationLockBypassCode": null,
            "emailAddress": "xxx",
            "azureActiveDirectoryDeviceId": "xxx",
            "azureADDeviceId": "xxx",
            "deviceRegistrationState": "registered",
            "deviceCategoryDisplayName": "Unknown",
            "isSupervised": true,
            "exchangeLastSuccessfulSyncDateTime": "0001-01-01T00:00:00Z",
            "exchangeAccessState": "none",
            "exchangeAccessStateReason": "none",
            "remoteAssistanceSessionUrl": null,
            "remoteAssistanceSessionErrorDetails": null,
            "isEncrypted": true,
            "userPrincipalName": "xxx",
            "model": "iPhone 11",
            "manufacturer": "Apple",
            "imei": "xxx",
            "complianceGracePeriodExpirationDateTime": "9999-12-31T23:59:59Z",
            "serialNumber": "xxx",
            "phoneNumber": "xxx",
            "androidSecurityPatchLevel": "",
            "userDisplayName": "xxx",
            "configurationManagerClientEnabledFeatures": null,
            "wiFiMacAddress": "xxx",
            "deviceHealthAttestationState": null,
            "subscriberCarrier": "Telekom.de",
            "meid": "xxx",
            "totalStorageSpaceInBytes": 68719476736,
            "freeStorageSpaceInBytes": 16449011712,
            "managedDeviceName": "xxx",
            "partnerReportedThreatState": "unknown",
            "retireAfterDateTime": "0001-01-01T00:00:00Z",
            "preferMdmOverGroupPolicyAppliedDateTime": "0001-01-01T00:00:00Z",
            "autopilotEnrolled": false,
            "requireUserEnrollmentApproval": null,
            "managementCertificateExpirationDate": "2022-03-02T16:25:12Z",
            "iccid": null,
            "udid": null,
            "roleScopeTagIds": [],
            "windowsActiveMalwareCount": 0,
            "windowsRemediatedMalwareCount": 0,
            "notes": null,
            "configurationManagerClientHealthState": null,
            "configurationManagerClientInformation": null,
            "ethernetMacAddress": null,
            "physicalMemoryInBytes": 0,
            "processorArchitecture": "unknown",
            "specificationVersion": null,
            "joinType": "azureADRegistered",
            "skuFamily": "",
            "skuNumber": 0,
            "managementFeatures": "none",
            "enrollmentProfileName": null,
            "hardwareInformation": {
                "serialNumber": "xxx",
                "totalStorageSpace": 0,
                "freeStorageSpace": 0,
                "imei": "xxx",
                "meid": null,
                "manufacturer": null,
                "model": null,
                "phoneNumber": null,
                "subscriberCarrier": null,
                "cellularTechnology": null,
                "wifiMac": null,
                "operatingSystemLanguage": null,
                "isSupervised": false,
                "isEncrypted": false,
                "batterySerialNumber": null,
                "batteryHealthPercentage": 0,
                "batteryChargeCycles": 0,
                "isSharedDevice": false,
                "tpmSpecificationVersion": null,
                "operatingSystemEdition": null,
                "deviceFullQualifiedDomainName": null,
                "deviceGuardVirtualizationBasedSecurityHardwareRequirementState": "meetHardwareRequirements",
                "deviceGuardVirtualizationBasedSecurityState": "running",
                "deviceGuardLocalSystemAuthorityCredentialGuardState": "running",
                "osBuildNumber": null,
                "operatingSystemProductType": 0,
                "ipAddressV4": null,
                "subnetAddress": null,
                "esimIdentifier": null,
                "systemManagementBIOSVersion": null,
                "tpmManufacturer": null,
                "tpmVersion": null,
                "sharedDeviceCachedUsers": []
            },
            "deviceActionResults": [],
            "usersLoggedOn": [
                {
                    "userId": "xxx",
                    "lastLogOnDateTime": "2021-12-08T09:21:14.406Z"
                }
            ],
            "chromeOSDeviceInfo": []
        },

Info von Microsoft dazu unter: managedDevice resource type – Microsoft Graph beta | Microsoft Docs

Microsoft Graph Explorer Filter der Geräte nach Operating System

https://graph.microsoft.com/beta/deviceManagement/managedDevices?filter=operatingSystem eq 'iOS'

Microsoft Graph Explorer Device Compliance Policies abfragen

Wer mehr über die Device Policies erfahren möchte, der kann wie folgt vorgehen, wobei das Prinzip, mit den richtigen Parametern, das selbe ist.

https://graph.microsoft.com/beta/deviceManagement/deviceCompliancePolicies
image 9
{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#deviceManagement/deviceCompliancePolicies",
    "value": [
        {
            "@odata.type": "#microsoft.graph.iosCompliancePolicy",
            "roleScopeTagIds": [
                "0"
            ],
            "id": "xxx",
            "createdDateTime": "2019-09-06T08:20:55.7969359Z",
            "description": "",
            "lastModifiedDateTime": "2020-03-31T14:03:23.3276575Z",
            "displayName": "iOS - Device Compliance - Baseline",
...

Microsoft Graph Explorer Device Compliance Policies mit selektiertem Namen

Will man die Ausgabe auf Namen der Policies filtern, sieht die URL wie folgt aus:

https://graph.microsoft.com/beta/deviceManagement/deviceCompliancePolicies?select=displayName

Microsoft Graph Explorer Device Compliance Policiy Summary

Eine Übersicht über den Compliantstatus kann man mit der deviceCompliancePolicyDevieStateSummary erhalten.

https://graph.microsoft.com/beta/deviceManagement/deviceCompliancePolicyDeviceStateSummary
{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#deviceManagement/deviceCompliancePolicyDeviceStateSummary/$entity",
    "inGracePeriodCount": 0,
    "configManagerCount": 0,
    "id": "xxx",
    "unknownDeviceCount": 18,
    "notApplicableDeviceCount": 0,
    "compliantDeviceCount": 1205,
    "remediatedDeviceCount": 0,
    "nonCompliantDeviceCount": 195,
    "errorDeviceCount": 0,
    "conflictDeviceCount": 0
}

Microsoft Graph Explorer Filter nach NonCompliant Devices

Um nur die Geräte anzuzeigen die nicht compliant sind, kann der Filter wie folgt gesetzt werden.

https://graph.microsoft.com/beta/deviceManagement/managedDevices?filter=complianceState eq 'noncompliant'
image 2
{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#deviceManagement/managedDevices",
    "@odata.count": 195,
    "value": [
        {
...

Hier noch ein Beispiel für alle non compliant Geräte mit iOS Betriebssystem.

https://graph.microsoft.com/beta/deviceManagement/managedDevices?filter=operatingSystem eq 'iOS' and complianceState eq 'noncompliant'
image 3

Mirosoft Graph Explorer Filter nach Jailbroken Devices und selektiertem UserDisplayName

https://graph.microsoft.com/beta/deviceManagement/managedDevices?filter=jailBroken eq 'True'&select=userDisplayName

Microsoft Graph Explorer fehlende Rechte

Wer bei einer Abfrage eine Fehlermeldung über fehlende Berechtigungen erhält,

image 4

sollte für Details in den Bereich “Response preview” schauen.

image 5

    "error": {
        "code": "Forbidden",
        "message": "{  \"_version\": 3,  \"Message\": \"Application is not authorized to perform this operation. Application must have one of the following scopes: DeviceManagementConfiguration.Read.All, DeviceManagementConfiguration.ReadWrite.All - 

Hier ist gut zu sehen, dass eine dieser beiden Berechtigungen, DeviceManagementConfiguration.Read.All, DeviceManagementConfiguration.ReadWrite.All, gesetzt werden müssen. Die Berechtigungen werden dann über den Schalter “Modify permissions (Preview)” gesetzt:

image 7

Hier auf den Button “Consent” klicken. Ich habe nur die “…Read.All” Berechtigungen erlaubt.

image 8

Danach kann die Query dann erfolgreich ausgeführt werden.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert