Intune Policy Compliance - API or PowerShell Command to Fetch Device Associations and Compliance Status

Swahela Mulla 90 Reputation points
2023-08-03T15:27:07.1533333+00:00

Hi everyone,

I'm looking for a way to retrieve policy compliance information in Microsoft Intune programmatically. Specifically, I need to fetch the number of devices associated with each policy and their compliance status.

I've explored the Intune report export Graph API, but unfortunately, it doesn't seem to have a specific report for policy compliance and also, I found one API but that API also not working showing error.

Intune reports Link :
https://video2.skills-academy.com/en-us/mem/intune/fundamentals/reports

aggregatedPolicyCompliance resource type :

https://video2.skills-academy.com/en-us/graph/api/managedtenants-managedtenant-list-aggregatedpolicycompliances?view=graph-rest-beta&tabs=http

Error from Above API

{
    "error": {
        "code": "BadRequest",
        "message": "Request not applicable to target tenant.",
        "innerError": {
            "date": "2023-04-18T02:52:32",
            "request-id": "3a2133e1-xxxxxxxxxxxxxx-f1fbd71f05be",
            "client-request-id": "3a2133e1-xxxxxxxxxxxxxx-f1fbd71f05be"
        }
    }
}

Can anyone guide me on how to achieve this? Are there any other APIs or PowerShell commands that I can use to get this information or any alternate solution for this?

Your assistance is highly appreciated!

Thank you.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,235 questions
Microsoft Intune Compliance
Microsoft Intune Compliance
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.Compliance: Adhering to rules, standards, policies, and laws.
143 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,657 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,266 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lu Dai-MSFT 28,366 Reputation points
    2023-08-04T01:56:17.8333333+00:00

    @Swahela Mulla Thanks for posting in our Q&A.

    For this issue, I have tried it in my environment. It shows the same error as yours. Graph issue is more related to develop scope. Honestly, I'm not familiar with it and the resource I get is limited. Given this situation, it is suggested to create a Premier or Unified support ticket to get more help. Here is the support link:

    https://video2.skills-academy.com/en-us/mem/get-support#premier-and-unified-support-options

    Hope everything goes well with you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments