After recently having the Intune Wipe action fail to Wipe PCs though it removes the PC from Intune, I worry we could have more unmanaged yet fully functional PCs in the field. Is there a way to require an Autopiloted PC to be Intune managed, either by automatically re-enrolling it in Intune (preferred) or making it painfully obvious there is a problem? And, is there a way to find PCs that have escaped from being managed?
I asked this on Reddit and the answer was to use Conditional Access. However, everything I am finding in regards to Conditional Access means using the "Require a device to be marked as compliant" policy. This will be a problem, until we have worked through bringing more than 500 computers back into compliance. These were found after creating some very reasonable compliance policies, while we slowly move Configuration Manager built and hand-crafted PCs to being fully Intune managed.
The closest I have come to finding the unmanaged was the following Powershell query. Unfortunately, a successful Intune Wipe puts a PC into the same state as those I am seeking. So most of the PCs returned are likely PCs sitting on a shelf waiting to be redeployed. As Azure AD objects created by an Autopilot import start as not being enabled, one thought I have had was to un-enable all devices returned by this query. This would put the accounts of machines sitting on a shelf into a safer position AND would break machines that have escaped management.
Get-AzureADDevice -All $true -Filter "startswith(DeviceOSType,'Windows') and DeviceTrustType eq 'AzureAd'" | Where-Object {-not $_.IsManaged}