{"id":2829,"date":"2018-04-10T12:15:41","date_gmt":"2018-04-10T11:15:41","guid":{"rendered":"https:\/\/www.lieben.nu\/liebensraum\/?p=2829"},"modified":"2018-04-10T12:15:41","modified_gmt":"2018-04-10T11:15:41","slug":"remove-staleintunedevices-using-a-scheduled-azure-runbook","status":"publish","type":"post","link":"https:\/\/lieben.nu\/liebensraum\/2018\/04\/remove-staleintunedevices-using-a-scheduled-azure-runbook\/","title":{"rendered":"Remove-StaleIntuneDevices using a scheduled Azure Runbook"},"content":{"rendered":"<p>I recently came upon a really cool <a href=\"https:\/\/blogs.technet.microsoft.com\/smeems\/2018\/03\/07\/device-cleanup-with-graph-api\/\" target=\"_blank\" rel=\"noopener\">post by Josh and Sarah that explains how to clean up stale devices in Intune using the Graph API<\/a>.<\/p>\n<p>As I want to run this from an Azure runbook, silently, I had to modify it a little so it automatically consents to azure app permissions and logs in silently. If you&#8217;d like to use it, feel free to add it from the Azure gallery (search for Lieben) or download it yourself.<\/p>\n<p>Make sure you&#8217;ve also imported the AzureAD and AzureRM modules into your automation account, and configured a credential object for the script to use.<\/p>\n<p>GitLab:\u00a0<a href=\"https:\/\/gitlab.com\/Lieben\/assortedFunctions\/blob\/master\/Remove-StaleIntuneDevicesForAzureAutomation.ps1\" target=\"_blank\" rel=\"noopener\">Remove-StaleIntuneDevicesForAzureAutomation.ps1<\/a><\/p>\n<p>Technet:\u00a0<a href=\"https:\/\/gallery.technet.microsoft.com\/scriptcenter\/Remove-Stale-Intune-4b07488a\" target=\"_blank\" rel=\"noopener\">Remove-Stale-Intune-4b07488a<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently came upon a really cool post by Josh and Sarah that explains how to clean up stale devices in Intune using the Graph API. As I want to run this from an Azure runbook, silently, I had to modify it a little so it automatically consents to azure app permissions and logs in &hellip; <a href=\"https:\/\/lieben.nu\/liebensraum\/2018\/04\/remove-staleintunedevices-using-a-scheduled-azure-runbook\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Remove-StaleIntuneDevices using a scheduled Azure Runbook<\/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":[4,5,22,39],"tags":[],"class_list":["post-2829","post","type-post","status-publish","format-standard","hentry","category-automation","category-azure","category-intune","category-powershell"],"_links":{"self":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/2829","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=2829"}],"version-history":[{"count":0,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/2829\/revisions"}],"wp:attachment":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/media?parent=2829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/categories?post=2829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/tags?post=2829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}