Get Actions for noncompliance via Graph API

This is a knowledgebase item how to get the actions for a noncompliance device for a Compliancy Policy via Graph API with the deviceComplianceScheduledActionForRule action.

I submitted on August 25, 2022, feedback to Microsoft to update their documentation but in the meantime. Hope that it helps you out.

The issue

If you open the Microsoft Graph API documentation and you are searching for the noncompliance action, then you end up with the deviceComplianceScheduledActionForRule action. The documentation states to use the following HTTP request to list the actions:

GET https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/scheduledActionsForRule

And to get all the actions via the following HTTP request

GET https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/scheduledActionsForRule/{deviceComplianceScheduledActionForRuleId}

But if you enter one of the Graph API HTTP requests with the ID of your Compliance Policy, you will get a Graph API error

The solution to get the actions via the Graph API

I did some research through the developer menu in my Microsoft Edge browser while clicking through the Intune Portal to my Compliance Policy and I found the following Graph API.

GET https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}?$expand=scheduledActionsForRule

Note. If you want to know which Graph API requested are be used by Intune. Open the developer Tools via CTRL+Shift+I and select Network. Click in the Intune portal and you will get all the actions and you can find in the list multiple actions and some of those actions are Graph API request. Open the request and you can see which Graph API URL have been used.

After I entered that URL in the Graph API, I get the 200 – Ok response and I was able to list all my configured Actions for noncompliance.

And with the following Graph API URL, I was able get the details and configuration of the Actions for noncompliance

GET https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}?$ =scheduledActionsForRule($expand=scheduledActionConfigurations)

With this new Graph API URL, you can get the action that has been configured in the Compliance Policy and you can automate duplications or list or export the fully Compliance policy and hopefully Microsoft will update their documentation ASAP.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.