Inspired by the cool blog article about collecting custom MacOS inventory data to an Log Analytics Workspace:
I modified his script to upload the data using our Azure Function App from Part 1 of our Reporting Series to our existing Cosmos DB. If you haven’t seen it, check it out now: Part 1
As a short reminder, how this will all fit in the whole architecture of our reporting, we built an Azure Function App that will take the inventory data from our (windows) clients and now also from our macOS Clients and writes it into our centralized Cosmos DB, which we will query from Power BI.
Azure Cosmos DB
Let’s start with adding the new Container for our MacOS Data to our Cosmos DB. The new Container id will be “MacOSInventoryContainer” and the Partition key is “/id” which contains the Intune managed device id as in all of our other Containers, so we can easily build the relationships in PowerBI later.
Before we can use the new script, we have to modify the script from GitHub, to point to our Azure Function App. https://github.com/mmeierm/Scripts/blob/main/Inventory/MacOS_ClientInventory_CosmosDB_AzureFunction.sh
Simply add the Function App URL in Line 93 to your environment:
Now that we have configured everything that we need, we can deploy the bash script via Intune by using the Shell Scripts option.
Give it a name:
Upload the script, set it to run silent and set the Script frequency to your needs.
Once you assign it to your devices, at the next check-in you should be able to see data in the database:
Now that we have our custom inventory available in the Cosmos DB, we can leverage this data in our Power Bi Reports as well. Simply add the new container:
Select transform data and expand our columns as needed:
Once the data is loaded to Power Bi, we can check the relationships, that should be automatically created and should basically be a 1:1 relationship between the id fields, as mentions above contains the Intune managed device id, which is unique.
If everything went right, you should be able to add the new fields like members of local admin groups to your reports: