REFERENCE

The Intune compliance signal

You manage devices with Intune, and you want a device that is behind on its attested app updates to read non-compliant, so Conditional Access can keep it away from company data until it is patched.

UPDATED

Attestree patches the apps; Intune keeps device compliance. This is the one thing handed between them. Since agent 0.249.1, after each completed cycle the agent writes a small file saying which managed packages on the device are behind the version your server wants there. An Intune custom-compliance discovery script reads that file, and a compliance policy turns it into compliant or not compliant. A Conditional Access policy that requires a compliant device can then keep a device that is behind out of, for example, Exchange Online until the agent has patched it.

Two things hold however you configure it:

  • It never withholds an update. The agent installs whatever the file says. A non-compliant device is exactly the one that needs its updates.
  • Presence, never usage. The file says which packages are behind and at which versions. It carries no run counts, durations, times of use or per-user activity, and no user name or SID: a per-user package counts, but its entry does not name the user.

What the agent writes

The file is C:\ProgramData\Wep\Compliance\presence.json. The agent rewrites it after every cycle that reached your server and completed; a cycle that never reached your server writes nothing, so the file ages. The folder and the file are readable by SYSTEM only, so an administrator needs a SYSTEM shell to look at it.

It holds a schema version (1), when it was written, the agent’s version, how many packages your server manages on the device, how many of them are behind, and up to 50 of those, each with its package manager, package id, installed version (empty when it is not installed) and the version your server wants. The count is exact even when the list is cut.

A package is behind when your server wants it at a concrete version and the device has an older one, or, for an install, none at all. A package on a floating latest target, a package to be removed and an update-only package that is not installed never count. The file reflects what the cycle read before it ran its steps, so a package that cycle upgraded still reads behind until the next one.

What Intune receives

The Intune Management Extension runs the discovery script as SYSTEM, in 64-bit PowerShell. It returns three settings:

  • WepAttestationState: current, or unknown.
  • WepAttestedBehind: how many managed packages are behind, or -1 when the state is unknown.
  • WepAttestedPending: the packages that are behind, as <package> <installed> -> <target>, separated by semicolons, with none for one not yet installed. It is cut at 1,500 characters, so the whole output stays inside Intune’s 2,048-character limit.

The state reads unknown when the file is missing, more than 72 hours old, dated more than an hour ahead of the device’s clock, unreadable, of a schema the script does not know, a link rather than a file, or owned by anyone but SYSTEM or the Administrators group. Anyone else could have planted it.

The script needs only what PowerShell’s Constrained Language Mode allows, so it runs unsigned under an App Control (WDAC) policy that puts unsigned scripts in that mode.

The rules, and what unknown means

The shipped rules make a device compliant when WepAttestationState is current and WepAttestedBehind is 0. So unknown is non-compliant: Attestree cannot vouch for a device that has not completed a cycle with your server for three days, or whose agent is not running. An offline device turns non-compliant after three days, and the message Intune shows its user asks for the device to be connected and the agent service running.

You can choose the other way and act only on a known backlog: drop the rule on WepAttestationState, and let the rule on WepAttestedBehind accept anything up to 0, so the -1 of an unknown state passes. A device whose agent was removed then reads compliant as well.

Setting it up in Intune

  1. Under Devices › Compliance › Scripts, add the discovery script for Windows 10 and later. It runs as the system, not with the signed-in user’s credentials, and in the 64-bit PowerShell host; leave the signature check off unless you sign it with a certificate your devices trust.
  2. In a Windows 10 and later compliance policy, under Custom Compliance, select that script and upload the rules file.
  3. Set the actions for non-compliance with a grace period long enough for updates to land, and assign the policy to the device groups that run the agent.
  4. Require a compliant device in the Conditional Access policies that should depend on it.

Intune runs discovery scripts on its own schedule, roughly every eight hours and when the device syncs, not on the agent’s. The Intune Management Extension logs each run in C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\HealthScripts.log.

The discovery script and the rules file are not published on this site yet. This page describes what they do, so you can judge the signal before they are.

Laptops that leave the office

A laptop that cannot reach your server completes no cycles, so its file ages and reads unknown after 72 hours: non-compliant under the shipped rules. If your laptops roam, the public listener and a front door keep them completing cycles, and so keep the signal current, without a VPN.

Where this stops

  • You cannot set it up from this site alone until the script and rules file are published.
  • Intune’s schedule, not the agent’s, decides when a patched device reads compliant again.
  • It reports whether the device is behind on what your server wants, nothing more. It is no detection rule for one app; for that question, see an Intune detection rule for a winget app.
  • An agent older than 0.249.1 writes no file, so its device reads unknown.