{"id":3396,"date":"2020-01-25T11:53:58","date_gmt":"2020-01-25T10:53:58","guid":{"rendered":"https:\/\/www.lieben.nu\/liebensraum\/?p=3396"},"modified":"2020-01-25T11:53:58","modified_gmt":"2020-01-25T10:53:58","slug":"ps-oneliner-to-get-local-device-compliance-state","status":"publish","type":"post","link":"https:\/\/lieben.nu\/liebensraum\/2020\/01\/ps-oneliner-to-get-local-device-compliance-state\/","title":{"rendered":"PS Oneliner to get local device compliance state"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"64\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2020\/01\/intune_get_compliance_state_locally.png\" alt=\"\" class=\"wp-image-3397\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2020\/01\/intune_get_compliance_state_locally.png 801w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2020\/01\/intune_get_compliance_state_locally-300x24.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2020\/01\/intune_get_compliance_state_locally-768x61.png 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><figcaption>Getting local Azure AD \/ Intune device compliance state with a PowerShell Oneliner<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The Graph API and Intune portal(s) give insight into device compliance status, but what about a local equivalent? How can we <span style=\"text-decoration: underline;\">locally<\/span> detect from e.g. a script on a Windows 10 laptop if the device is compliant or not?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I couldn&#8217;t find any documentation, WMI properties or registry keys, but I did find that the Company Portal shows the compliance status and caches this in a file. So, although it isn&#8217;t pretty, I&#8217;ve settled for this method for now and created a <a href=\"https:\/\/microsoftintune.uservoice.com\/forums\/291681-ideas\/suggestions\/39519316-expose-compliance-state-to-local-processes\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"UserVoice item requesting a local W10 API\/regkey\/WMI property to query Intune compliance status of the device. (opens in a new tab)\">UserVoice item requesting a local W10 API\/regkey\/WMI property to query Intune compliance status of the device.<\/a><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n((get-content -Path (Get-Childitem \u2013Path (Join-Path $env:LOCALAPPDATA `\n-ChildPath \"Packages\\Microsoft.CompanyPortal_8wekyb3d8bbwe\\TempState\\ApplicationCache\") `\n-Include *.tmp* -File -Recurse | sort-object -Descending -Property lastWritetime)&#x5B;0] | convertfrom-json).data | convertfrom-json).ComplianceState\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>The Graph API and Intune portal(s) give insight into device compliance status, but what about a local equivalent? How can we locally detect from e.g. a script on a Windows 10 laptop if the device is compliant or not? I couldn&#8217;t find any documentation, WMI properties or registry keys, but I did find that the &hellip; <a href=\"https:\/\/lieben.nu\/liebensraum\/2020\/01\/ps-oneliner-to-get-local-device-compliance-state\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">PS Oneliner to get local device compliance state<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[7,22,39,1],"tags":[],"class_list":["post-3396","post","type-post","status-publish","format-standard","hentry","category-azuread","category-intune","category-powershell","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/comments?post=3396"}],"version-history":[{"count":0,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3396\/revisions"}],"wp:attachment":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/media?parent=3396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/categories?post=3396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/tags?post=3396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}