Get CPU and RAM from Intune and GraphAPI

Djordje Novakovic 626 Reputation points
2023-01-23T15:50:41.08+00:00

Hello,

I am collecting hardware information from Intune for our inventory system.

However, CPU and RAM information are not visible in Intune/Graph API.

I created deployed powershell script (which detects CPU and RAM information) in Intune to all Windows computers and now that information is visible in GraphAPI.

I used this tutorial: [https://techcommunity.microsoft.com/t5/device-management-in-microsoft/how-to-collect-custom-inventory-from-azure-ad-joined-devices/ba-p/2280850

PS script deployed to all machines:

$cpu = Get-WmiObject -Class Win32_Processor  |  select @{n="ComputerName";e={$_.systemname}},@{n="CPU";e={$_.name}}
$model = Get-WmiObject -Class Win32_ComputerSystem | Select-Object Model,Manufacturer
$serialNumber = Get-WmiObject win32_bios | Select-Object SerialNumber
$memory = (Get-WmiObject Win32_PhysicalMemory  | Measure-Object -Sum -Property Capacity).Sum / (1024*1024*1024) 
[PSCUStOMOBJECT]@{
    "ComputerName"=$env:COMPUTERNAME;
    "RAM(GB)"=$memory;
    "CPU"=$cpu.CPU;
    "Model"=$model.Model;
    "SerialNumber"=$serialNumber.SerialNumber
    } | ConvertTo-Json

When I call Graph API to get results in powershell I receive "something like" JSON format, it is not valid JSON and I am not able to use it like regular JSON file:

User's image

When I call it from Azure API management it is the same situation, it has extra curly brackets:

User's image

Does anyone know how to fix this output and make it useful?

Or anyone has experience how to get CPU and RAM data from Intune?

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,015 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
5,060 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Djordje Novakovic 626 Reputation points
    2023-01-23T15:58:18.7733333+00:00

    This is "resultMessage" and how it looks like in raw response:

    User's image

    "resultMessage": "{"ComputerName":"","RAM(GB)":16,"CPU":"Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz","Model":"Latitude 5501","SerialNumber":"***"}"

    0 comments No comments

  2. Djordje Novakovic 626 Reputation points
    2023-01-23T15:59:56.16+00:00

    Test comment

    0 comments No comments

  3. Djordje Novakovic 311 Reputation points
    2023-02-01T11:37:47.1966667+00:00

    We found a workaround solution, send information to Log Analytics and after that API pulls data.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.