How to collect custom inventory from Azure AD Joined devices

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:

MikeGriz_0-1619043818972.png

 

Beautified:

 

{ "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.

MikeGriz_2-1619043913367.png


Tip: <scriptId> is stored in the URL

MikeGriz_3-1619043946125.png


You can access the data via the following Graph endpoint in graph explorer
https://graph.microsoft.com/beta/deviceManagement/deviceManagementScripts/<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”:

MikeGriz_4-1619043988087.png


How do I see the data from all devices?
Prerequisites:
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

 

 

MikeGriz_0-1619044884955.png


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

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

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