The guide describes how to setup a Patch My PC Power BI report for Intune using Azure automation to regularly export data from Intune into Azure blob storage as the data source for the report.
In this guide we will create a Power BI report from a template to report on apps and updates in Intune managed by the Patch My PC publishing service. Patch My PC is a great tool for keeping 3rd party applications up-to-date. The report is only for applications in Intune and not ConfigMgr.
As Power BI does not natively support connections to Microsoft Graph, we will use Azure automation to regularly export data from Intune using the Microsoft Graph REST APIs and save this as CSV files in Azure blob storage. Power BI supports the use of files in an Azure storage account as a data source, and the Power BI service also supports scheduled refresh on this data source, so your report can automatically stay up to date.
Although we create the required Azure resources in this guide, you may wish to use resources you already have in Azure for this.
Create / configure an Azure automation account
Grant API permissions to the managed identity or Run as account
Create / configure an Azure storage account
Create the Automation runbook
Create the Power BI report
A working Patch My PC for Intune installation with apps / updates created and assigned
Some familiarity with Azure administration
Some familiarity creating Power BI reports
Appropriate permissions to create / configure the Azure resources
Cast dates into "s" (sortable) format to provide consistency and correct interpretation of dates by the PowerBI report. Increased the timeout for 429 http status codes from 5 minutes to 10 minutes.
Removed the "Write-Output" command from the Get-PmpAppsList function because the results are sent to a variable and any additional output would break the list of apps returned.
Added retry logic with a 5-minute timeout on the Get-DeviceInstallStatusReport function in the runbook, to handle non-success return codes.
Updated both the runbook and the Power BI template to handle the scenario where they may be either no app or no updates deployed.
Added code to the Azure automation runbook to fix a bug where the PowerBI report would error if there were no data returned for the statusoverview or deviceinstallstatus reports.
Updated the Power BI template with a new-look dark theme. Added an "Application counts" chart on the installs report pages, as well as device and install counts, and an "install state" filter.
Updated the Remove-MSGraphExportJobDuplicates function with some more efficient code that (in testing) is around 30% quicker. Thanks to Yannick Van Landeghem for the tip on this!
Major rewrite to move away from the reports/exportJobs Graph endpoint due to much tighter limits put in place by MS for frequent requests for jobs. Switched back to the reports/getDeviceInstallStatusReport endpoint again and used looping to overcome the current 50 item limit per request.
Added a filter to the Request-ExportJobs function in the automation runbook to only include install states that are NOT 'not applicable'. This significantly reduces the overall processing time of the runbook where apps are targeted to a large number of devices for which the app is not applicable to that device.
Added some retry logic to the Request-ExportJobs function in the runbook to handle when Graph returns a bad request response. This is in response to changes made to service limits in MS Graph around 2021-09-24.
Switched from using the deviceManagement/reports/getDeviceInstallStatusReport Graph endpoint to exportJobs for the device installation status data due to the limitation of the endpoint only returning 50 results per call.
Added a function in the runbook to create a unique result set for the device installation status data by including only the most recent entry per device
Released version 1.1 of the Power BI report template removing the 'Not applicable' status from the donut charts for a better view.
Fixed an issue with the automation runbook where it would fail if the number of apps or updates in an export job was a multiple of 20.
Updated the runbook script to include better error handling and some retry logic in case the http 504 error (gateway timeout) is returned.