{"id":29929,"date":"2023-08-19T17:08:40","date_gmt":"2023-08-19T17:08:40","guid":{"rendered":"https:\/\/endusersupports.com\/?p=29929"},"modified":"2023-08-22T12:57:10","modified_gmt":"2023-08-22T12:57:10","slug":"intune-automation-with-powershell","status":"publish","type":"post","link":"https:\/\/endusersupports.com\/index.php\/2023\/08\/19\/intune-automation-with-powershell\/","title":{"rendered":"Intune Automation with PowerShell"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"29929\" class=\"elementor elementor-29929\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-727b2e2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"727b2e2\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9b74ebd\" data-id=\"9b74ebd\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-78a9992 elementor-widget elementor-widget-text-editor\" data-id=\"78a9992\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><strong><span style=\"color: #ffffff;\">How to Automate Intune report with PowerShell<\/span><\/strong><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4c8cfbd elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"4c8cfbd\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-16f11cc\" data-id=\"16f11cc\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-659f607 elementor-widget elementor-widget-text-editor\" data-id=\"659f607\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This article will help you automation Intune report with the PowerShell.<\/p><p>Benefits-<\/p><ul><li>You don&#8217;t required to login in Intune console, PowerShell will do it for you.<\/li><li>You don&#8217;t required to enter Username and Password to access the Intune data.<\/li><li>It will be a Passwordless script, you can schedule this report.<\/li><\/ul><p><strong>Configuration Required-\u00a0<\/strong><\/p><p>You have to create a App registration in Azure AD. Follow my article to create App Registration <a href=\"https:\/\/endusersupports.com\/index.php\/2023\/08\/13\/app-registration-for-intune\/\" target=\"_blank\" rel=\"noopener\">How to create Intune App Registration.\u00a0<\/a><\/p><p>Once you done with the App registration then collect\u00a0<strong>ApplicationID, TenantID and Secret Code\u00a0<\/strong>from you app Registration the use the below PowerShell code.<\/p><p>Download the script from my Github profile &#8211; <a href=\"https:\/\/github.com\/harvansh007\/Intune-Device-Data-with-Powershell\/blob\/main\/Intune%20All%20Device%20List\" target=\"_blank\" rel=\"noopener\">Intune Device List.ps1<\/a><\/p><p>Below script will pull all devices data from the Intune.<\/p><blockquote><p style=\"padding-left: 40px;\"># Script Name &#8211; Get All Device list from Intune<br \/># Script Owner &#8211; Harvansh Singh<br \/># Required details &#8211; This is a passwordless authentication script that will help you to full data from Intune.<br \/># Reuired field &#8211; $TenantID, $AppID, $AppSecret<\/p><p style=\"padding-left: 40px;\"># To get the Token key<\/p><p style=\"padding-left: 40px;\">[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12<br \/>$TenantID = &#8220;&#8221;<br \/>$AppID = &#8220;&#8221;<br \/>$AppSecret = &#8220;&#8221;<\/p><p style=\"padding-left: 40px;\">$ResourceAppIDuri = &#8220;https:\/\/graph.microsoft.com&#8221;<br \/>$oauthUri = &#8220;https:\/\/login.microsoftonline.com\/$TenantID\/oauth2\/token&#8221;<br \/>$body = [Ordered] @{<br \/>resource = &#8220;$ResourceAppIDuri&#8221;<br \/>client_id = &#8220;$AppID&#8221;<br \/>client_secret = &#8220;$AppSecret&#8221;<br \/>grant_type = &#8216;client_credentials&#8217;<br \/>}<br \/>$response = Invoke-RestMethod -Method Post -Uri $oauthUri -Body $body -ErrorAction Stop<br \/>$aadToken = $response.access_token<\/p><p style=\"padding-left: 40px;\">$headers = @{<br \/>&#8216;Content-Type&#8217; = &#8216;application\/json&#8217;<br \/>Accept = &#8216;application\/json&#8217;<br \/>Authorization = &#8220;Bearer $aadToken&#8221;<br \/>}<\/p><p style=\"padding-left: 40px;\">$uri = &#8220;https:\/\/graph.microsoft.com\/beta\/deviceManagement\/managedDevices&#8221;<br \/>$Devicelist = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers<br \/>$devicedata = $Devicelist.value | Select-Object deviceName, joinType, deviceEnrollmentType,operatingSystem, complianceState, enrolledDateTime, lastSyncDateTime <br \/>$devicedata | Export-Csv &#8220;D:\\Intune Automation\\All Devices.csv&#8221; -NoTypeInformation<\/p><\/blockquote><p>\u00a0You device output will save on D:\\Intune Automation\\All Devices.csv Drive.\u00a0<\/p><h1><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-29930\" src=\"http:\/\/endusersupports.com\/wp-content\/uploads\/2023\/08\/Intune-All-Device-List.jpg\" alt=\"\" width=\"642\" height=\"394\" srcset=\"https:\/\/endusersupports.com\/wp-content\/uploads\/2023\/08\/Intune-All-Device-List.jpg 642w, https:\/\/endusersupports.com\/wp-content\/uploads\/2023\/08\/Intune-All-Device-List-300x184.jpg 300w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><\/h1><p><b>Below script will pull All Operating System count data from the Intune.<\/b><\/p><p>Download this script from my Gitbub profile <a href=\"https:\/\/github.com\/harvansh007\/Intune-Device-Data-with-Powershell\/blob\/main\/Intune%20Device%20Compliance%20List\">Get Device Compliance Count.ps1<\/a><\/p><blockquote><p># Script Name &#8211; Get Device Complaince Count <br \/># Script Owner &#8211; Harvansh Singh<br \/># Required details &#8211; This is a passwordless authentication script that will help you to full data from Intune.<br \/># Reuired field &#8211; $TenantID, $AppID, $AppSecret<br \/># To get the Token key<\/p><p><br \/>[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12<br \/>$TenantID = &#8220;&#8221;<br \/>$AppID = &#8220;&#8221;<br \/>$AppSecret = &#8220;&#8221;<\/p><p>$ResourceAppIDuri = &#8220;https:\/\/graph.microsoft.com&#8221;<br \/>$oauthUri = &#8220;https:\/\/login.microsoftonline.com\/$TenantID\/oauth2\/token&#8221;<br \/>$body = [Ordered] @{<br \/>resource = &#8220;$ResourceAppIDuri&#8221;<br \/>client_id = &#8220;$AppID&#8221;<br \/>client_secret = &#8220;$AppSecret&#8221;<br \/>grant_type = &#8216;client_credentials&#8217;<br \/>}<br \/>$response = Invoke-RestMethod -Method Post -Uri $oauthUri -Body $body -ErrorAction Stop<br \/>$aadToken = $response.access_token<\/p><p>$headers = @{<br \/>&#8216;Content-Type&#8217; = &#8216;application\/json&#8217;<br \/>Accept = &#8216;application\/json&#8217;<br \/>Authorization = &#8220;Bearer $aadToken&#8221;<br \/>} <br \/>$uri = &#8220;https:\/\/graph.microsoft.com\/beta\/deviceManagement\/managedDeviceOverview&#8221;<br \/>$OSlist = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers<br \/>$OSListdata = $OSlist.deviceOperatingSystemSummary | Export-Csv &#8220;D:\\Intune Automation\\OSList.csv&#8221; -NoTypeInformation<\/p><\/blockquote><p>Below is the script output.<\/p><p><img decoding=\"async\" class=\"aligncenter size-full wp-image-29971\" src=\"http:\/\/endusersupports.com\/wp-content\/uploads\/2023\/08\/OS-Data-from-Intune-.jpg\" alt=\"\" width=\"495\" height=\"376\" srcset=\"https:\/\/endusersupports.com\/wp-content\/uploads\/2023\/08\/OS-Data-from-Intune-.jpg 495w, https:\/\/endusersupports.com\/wp-content\/uploads\/2023\/08\/OS-Data-from-Intune--300x228.jpg 300w\" sizes=\"(max-width: 495px) 100vw, 495px\" \/><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>How to Automate Intune report with PowerShell This article will help you automation Intune report with the PowerShell. Benefits- You don&#8217;t required to login in Intune console, PowerShell will do it for you. You don&#8217;t required to enter Username and Password to access the Intune data. It will be a Passwordless script, you can schedule [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":29959,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-29929","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mem"],"views":2873,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/posts\/29929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/comments?post=29929"}],"version-history":[{"count":39,"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/posts\/29929\/revisions"}],"predecessor-version":[{"id":29977,"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/posts\/29929\/revisions\/29977"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/media\/29959"}],"wp:attachment":[{"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/media?parent=29929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/categories?post=29929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/endusersupports.com\/index.php\/wp-json\/wp\/v2\/tags?post=29929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}