Skip to main content
KBY Technologies Logo

Automating ServiceNow Tickets from Intune Non-Compliant Devices

A step-by-step operational runbook for routing Intune non-compliant device alerts through Azure Monitor into deduplicated ServiceNow incidents.

KBY Technologies11 min readIntermediate75 min
Automating ServiceNow Tickets from Intune Non-Compliant Devices

Advertising disclosure: this article includes partner links. KBY may earn a commission if you sign up or buy through one, at no extra cost to you. How we make money.

Before you begin

  • Basic KQL and Azure Monitor alert configuration
  • Familiarity with Intune compliance policies
  • Working knowledge of Logic Apps or Power Automate connectors

Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.

You have been asked to take a manual ticketing chore off the help desk, and the result has to be something people will trust to run on its own. Intune, Azure Monitor and ServiceNow each hold one piece of the picture, and the joins between them are where alerts get lost or repeated. Here is how to connect them, starting with the permissions you need.

#Operational requirement

The help desk currently raises a ServiceNow incident by hand every time someone notices a device sitting in the Intune “Non-compliant” bucket. That works at fifty devices. At five thousand it collapses: devices stay non-compliant for days, conditional access keeps blocking the user, and security only learns about a missed patch weeks later during an audit.

As the newly hired systems administrator, you are closing that gap without building a bespoke monitoring agent. You will route Intune compliance telemetry into Azure Monitor, trigger a scheduled query alert for each non-compliant device, and have that alert raise a ServiceNow incident automatically through the Table . No human touches this pipeline once it is live.

Get it wrong and you get one of two failures. Either the alert never fires and devices stay silently non-compliant, or it fires on every polling cycle and floods the service desk with duplicate tickets until someone disables the integration out of frustration. Both outcomes damage trust in automation faster than the manual process ever did.

#Prerequisites and required permissions

  • Intune Administrator or Global Administrator in Entra ID to configure diagnostic settings under Reports, plus Log Analytics Contributor on the target Log Analytics workspace; check Microsoft’s Intune diagnostic settings documentation for the current requirements.
  • An existing Log Analytics workspace, or Contributor rights to create one in the target subscription.
  • Monitoring Contributor on the workspace and on the resource group hosting the Logic App.
  • Logic App Contributor rights to build and publish the connector workflow.
  • A ServiceNow integration account that can create incident records through the API, with credentials issued by your platform team.
  • A change record raised before touching production alert rules or diagnostic settings — a botched rollout here generates noise the whole service desk sees.

#Step 1: Route Intune compliance telemetry to Log Analytics

Intune does not push compliance events anywhere by default; you must export them explicitly. In the Intune admin centre, go to Reports > Diagnostics settings and create a setting named intune-compliance-to-loganalytics. Select the DeviceComplianceOrg category and send it to your Log Analytics workspace. Microsoft describes this category as the organisational device compliance report with details of non-compliant devices: it is a periodic snapshot with one row per device, not a stream of per-device state-change events.

Plan around its timing. Microsoft documents that this report is exported to Azure Monitor once every 24 hours, at any point in that period, that it can take up to 48 hours to arrive, and that the export can duplicate data. This pipeline therefore raises tickets on a daily cycle, not within minutes; do not assume the pipe is broken after a few hours of silence.

Capture a screenshot of the diagnostic setting and the workspace’s Resource ID for the change record. Confirm rows return before continuing. Microsoft’s table reference documents columns including DeviceId, DeviceName, UPN, UserId and ComplianceState, but not the values ComplianceState takes, so list the values your tenant actually reports and note the one used for non-compliant devices; Step 2 needs it:

1IntuneDeviceComplianceOrg
2| where TimeGenerated > ago(2d)
3| summarize Devices = dcount(DeviceId) by ComplianceState

#Step 2: Build the scheduled query alert rule

In the workspace, go to Monitoring > Alerts > Create > Alert rule, scoped to the workspace. Use this KQL, which returns one row per non-compliant device in the export batch that has just landed, collapsing any duplicate rows the export contains. Replace the placeholder with the value you recorded in Step 1:

1IntuneDeviceComplianceOrg
2| where ingestion_time() > ago(1h)
3| where ComplianceState == "<non-compliant value from Step 1>"
4| summarize arg_max(TimeGenerated, DeviceName, UPN) by DeviceId
5| project DeviceId, DeviceName, UPN, ReportTime = TimeGenerated

The query filters on ingestion_time() rather than TimeGenerated so that each export batch is counted in the evaluation in which it lands, whatever time the report was generated.

Set the evaluation frequency to 1 hour to match that window, and the lookback period to at least a day so the rule’s own time range still includes the report’s TimeGenerated values; the portal enforces its own limits on both.

Measure table rows with the Count aggregation, split by dimensions on DeviceId, and set the threshold to greater than 0, so each non-compliant device fires its own alert instance. Leave automatic resolution on.

A stateful alert does not fire again for a device while it is still in the fired state, but the next hourly evaluation finds no new rows, so the device’s alert resolves and fires again when the next daily export lists it.

The alert rule therefore cannot deduplicate across days on its own; that is the job of the stable correlation key in Step 4.

Export the rule as an ARM template and store it in your infrastructure-as-code repository, not just the portal. Confirm the rule shows Enabled and that a manual Preview evaluation returns the expected rows from Step 1.

#Step 3: Create the Action Group and Logic App shell

Create an Action Group in the same resource group named ag-intune-noncompliance-servicenow, with a single Logic App action. Build the Logic App with an request trigger; the common alert schema posts its JSON payload automatically once linked.

Intune non-compliant device automation ServiceNow

Add a Parse JSON action using Microsoft’s common alert schema sample for log search alerts (Log Alerts V2) as the sample payload, so later steps can reference alertContext, essentials.alertRule and essentials.firedDateTime cleanly. This matters because the raw payload structure changes if you ever move off the common schema, and unparsed field access then breaks silently.

Trigger the Logic App manually with a sample payload and confirm Parse JSON runs without a schema validation failure.

#Step 4: Call the ServiceNow Table API to raise the incident

Add an HTTP action after Parse JSON, targeting the ServiceNow incident table endpoint. Store the integration credentials in Azure Key Vault, give the Logic App’s managed identity permission to read that secret, and add the Key Vault connector’s Get secret action before the HTTP action.

Set the HTTP action’s authentication type to Basic and take the username and password from the Get secret output. Turn on Secure Inputs and Secure Outputs in the settings of both the Get secret action and the HTTP action, otherwise the secret value appears in plain text in the run history.

Do not hardcode credentials into the HTTP action — that is the fastest way to get this integration pulled during a security review.

1POST https://your-instance.service-now.com/api/now/table/incident
2Content-Type: application/json
3
4{
5 "short_description": "Intune non-compliant device: @{body('Parse_JSON')?['data']?['alertContext']?['condition']?['allOf'][0]?['dimensions'][0]?['value']}",
6 "description": "Automated ticket raised from Azure Monitor scheduled query alert. Alert fired at @{body('Parse_JSON')?['data']?['essentials']?['firedDateTime']}. Device query results: @{body('Parse_JSON')?['data']?['alertContext']?['condition']?['allOf'][0]?['linkToFilteredSearchResultsUI']}",
7 "urgency": "2",
8 "impact": "2",
9 "category": "Endpoint Management",
10 "assignment_group": "Endpoint Operations",
11 "correlation_id": "intune-noncompliance-@{body('Parse_JSON')?['data']?['alertContext']?['condition']?['allOf'][0]?['dimensions'][0]?['value']}"
12}

The correlation_id field is what keeps the queue from drowning. It is built from the DeviceId dimension rather than alertId, because alertId identifies a single alert instance and changes every time the alert fires, while the device ID stays the same for as long as the device does.

Configure a ServiceNow business rule on the incident table that rejects or auto-merges any submission whose correlation_id already has an open incident — without it, every daily export that still lists a device as non-compliant creates a fresh duplicate, because the alert rule and ServiceNow’s state model know nothing of each other.

Capture the ServiceNow incident number returned in the response and a copy of the deduplication business rule script. Confirm a single incident appears with the correct short description and assignment group.

#Step 5: Wire it live and run a controlled test

Link the Action Group to the alert rule from Step 2.

Then run a genuine test: take a lab device out of compliance deliberately — disable BitLocker on a pilot device enrolled in a policy requiring encryption — and wait for the device to check in and report its new state; Windows devices check in roughly every 8 hours by default, so trigger a sync from the device or the Intune admin centre to speed this up, then allow for the daily export from Step 1, which can take up to 48 hours.

Capture timestamped screenshots showing the device going non-compliant in Intune, the matching row in IntuneDeviceComplianceOrg, the alert firing in Azure Monitor’s Alert history, and the resulting ServiceNow incident with matching correlation_id.

Before calling this production-ready, remediate the test device, confirm that the next export no longer lists it as non-compliant and raises no new alert for it, and confirm the ServiceNow incident does not auto-close on resolution — that decision belongs to the service desk workflow, not the automation.

#Verification

Retain the exported ARM template, the Logic App run history export for the successful test, the ServiceNow deduplication business rule script, and the KQL used in the alert logic, filed against the change record reference. An auditor or a colleague debugging a missed ticket needs to reconstruct exactly what fired and why without re-deriving it from the portal.

Automating ServiceNow Tickets from Intune Non-Compliant Devices architecture diagram 2
CheckExpected evidenceWhere to find it
Telemetry ingestionRows returning from IntuneDeviceComplianceOrgLog Analytics > Logs
Alert firingFired state with correct timestampAzure Monitor > Alerts > History
Logic App executionSucceeded run, Parse JSON step greenLogic App > Overview > Runs history
Ticket creationSingle incident, correct correlation_idServiceNow incident table
DeduplicationNo duplicate incidents across two consecutive firesServiceNow incident list filtered by correlation_id

#Failure Modes

The most common failure is silence, not error. If the diagnostic setting points at the wrong workspace, or the DeviceComplianceOrg category is unticked, the alert rule evaluates against an empty table forever and never fires, with nothing visible anywhere. Always confirm the raw table query returns rows before trusting the alert.

A second trap is credential drift on the ServiceNow side. If the integration account’s password rotates under a corporate policy and nobody updates the Key Vault secret, the HTTP action returns an unauthorized response and the Logic App run shows Failed with no incident created — and nobody notices until the service desk asks why nothing has come through for a week. Set a Logic App run-failure alert of its own, routed to a channel your operations team actually watches.

Third, watch alert rule cost. Scheduled query rules on frequent evaluation windows against a noisy table can generate real Log Analytics query charges in large environments. Because this report arrives only once a day, there is nothing to gain from evaluating more often than the hourly frequency in Step 2.

Fourth, do not skip the correlation_id deduplication rule and assume the alert’s own auto-resolve logic prevents duplicate tickets. The alert rule and the ServiceNow incident lifecycle are two independent state machines. Nothing links them unless you build the link yourself.

#Rollback

If the pipeline needs to come out of production quickly — say, it is flooding the queue and the deduplication rule has a bug — work through these steps in order:

  1. Disable the Action Group link on the alert rule, or toggle the rule to Disabled, in Azure Monitor > Alerts > Alert rules. This stops new firings immediately without deleting configuration.
  2. In ServiceNow, bulk-update open incidents carrying the intune-noncompliance- correlation_id prefix to a holding state referencing the rollback change record, rather than closing them — the underlying compliance issues on those devices are still real.
  3. Disable the Logic App from its Overview page so the trigger stops firing and no new runs reach the HTTP action while you fix the deduplication logic; in-progress runs still finish.
  4. If the diagnostic setting itself is the source of unexpected data volume, remove it from Reports > Diagnostics settings in Intune; existing rows remain in Log Analytics for investigation.
  5. Re-enable in reverse order once fixed — diagnostic setting, alert rule, Logic App, Action Group link — with a verification checkpoint before each next step.

Following along? Tap a step’s number to tick it off.

Keep the diagnostic setting and alert rule templates version-controlled so rollback is a redeploy of a known-good state, not a manual reconstruction under pressure.

#Operational Summary

You have built a closed loop from Intune compliance evaluation through Log Analytics, an Azure Monitor scheduled query alert, and a Logic App that raises a deduplicated ServiceNow incident automatically.

The deliverable is not just a working pipeline — it is the evidence trail: exported templates, run histories, and a tested rollback path that lets you pull this out of production without leaving orphaned tickets or silent gaps in compliance monitoring.

Treat the correlation_id deduplication rule as the single most important control in this design; without it, automation meant to reduce noise becomes the thing generating it.

Evidence trail

Sources and verification

Primary documentation and external technical references used in this article.

  1. 01reviewing Intune logs using Azure Monitorlearn.microsoft.com
  2. 02Azure Monitor scheduled query alert rule documentationlearn.microsoft.com

About this page

Credited to

Dates

Published

Corrections

  • : Corrected during a review of published articles. Details
  • : Corrected during a review of published articles. Details

Found this useful? Follow KBY for more like it.

Reader Interaction

Comments

Add a thoughtful note on Automating ServiceNow Tickets from Intune Non-Compliant Devices. Comments are checked for spam and held for moderation before appearing.

Loading comments...

More from KBY that goes with this article.

Discover more

Was this useful?

Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.

Build practical engineering skills.

Receive new lessons, learning paths, practical exercises and early-career guidance.