How to collect custom inventory from Azure AD Joined devices

Posted by

This post has been republished via RSS; it originally appeared at: Device Management in Microsoft articles.

ConfigMgr admins love extending hardware inventory and collecting data from Windows devices.
Did you know Intune can do the same?!
The answer is Intune PowerShell scripts! Also known as SideCar… IME… Intune Management Extensions…

Well, IME is just another channel that runs parallel to MDM that sort of acts like the ConfigMgr client. We deliver different features over this channel: PowerShell scripts, Win32 apps, Proactive Remediation scripts, Win32 app log collection…

Can you give us an example?
Maybe you are interested to know more about Win32_BIOS.
Run the following PowerShell one-liner on a device



Get-WmiObject -Class Win32_BIOS | select CurrentLanguage, Description, EmbeddedControllerMajorVersion, EmbeddedControllerMinorVersion, Manufacturer, ReleaseDate, SerialNumber | ConvertTo-Json -Compress


Script outputs the following:





{ "CurrentLanguage": "en-US", "Description": "N2EET43W (1.25 )", "EmbeddedControllerMajorVersion": 1, "EmbeddedControllerMinorVersion": 13, "Manufacturer": "LENOVO", "ReleaseDate": "20191028000000.000000+000", "SerialNumber": "12345678" }


Let’s create an Intune PowerShell script and deploy it to some users/devices to demonstrate Win32_BIOS data as an example.


Tip: <scriptId> is stored in the URL


You can access the data via the following Graph endpoint in graph explorer<scriptID>/deviceRunStates?$expand=managedDevice


It turns out that we store the above-mentioned script output in a property on the service side. If you are familiar with Graph Explorer, then you can take a look at the results

In the property “resultMessage”:


How do I see the data from all devices?
Install-Module -Name Microsoft.Graph.Intune

You need one more script to retrieve your results from Graph…


Update-MSGraphEnvironment -SchemaVersion 'beta' Connect-MSGraph $result = Invoke-MSGraphRequest -HttpMethod GET -Url 'deviceManagement/deviceManagementScripts/b113448a-528a-4beb-b7d5-381a117d5184/deviceRunStates?$expand=managedDevice' | Get-MSGraphAllPages $success = $result| Where-Object -Property errorCode -EQ 0 $resultMessage = $success.resultMessage $objResultMessage = $resultMessage | ConvertFrom-Json $objResultMessage | Out-GridView




You can store the data in Log Analytics, SQL etc and visualize the way you want.

This articles are republished, there may be more discussion at the original link. But if you found this helpful, you're more than welcome to let us know!

This site uses Akismet to reduce spam. Learn how your comment data is processed.