Microsoft Graph hardwareInformation query returning an error

Ross Lumby 20 Reputation points
2024-03-13T15:25:57.3333333+00:00

Hi all,

Sorry in advance - I am a powershell noob!

What I want to know is of all the laptops in our Intune, what language they each have set.

I have written the following powershell script to query all laptops running Windows and using a foreach loop to query each. I know there is an issue with hardwareInformation so I have included that in the $select

This is the code:

connect-mgGraph

$Devices = Get-MgBetaDeviceManagementManagedDevice -Filter "Operatingsystem eq 'Windows'"

Foreach ($Device in $Devices)
{
    $DeviceID = $Device.Id
    $URI = "https://graph.microsoft.com/beta/deviceManagement/manageddevices/$DeviceID?$select=hardwareInformation,OperatingSystemLanguage"
    Invoke-MgGraphRequest -Method GET -Uri $URI
}


This is the error:

User's image

Thanks for any help in advance!

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Other
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Answer accepted by question author
  1. Crystal-MSFT 54,191 Reputation points Microsoft External Staff
    2024-03-14T05:54:45.4233333+00:00

    @Ross Lumby, Thanks for posting in Q&A. Based on my test, the Graph API cannot by query via the URL we set. But we can query the information via the following code:

    connect-mgGraph
    $ManagedDevices = Get-MgBetaDeviceManagementManagedDevice -Filter "Operatingsystem eq 'Windows'"
    write-Host "The device Operating System Language information"
    Foreach ($ManagedDevice in $ManagedDevices){
    $hardware=(Get-MgBetaDeviceManagementManagedDevice -ManagedDeviceId $ManagedDevice.id -Property hardwareinformation).HardwareInformation
    $hardwareinfo=$hardware.OperatingSystemLanguage
    write-Host $ManagedDevice.DeviceName $ManagedDevice.id,$hardwareinfo
    }
    

    User's image

    Hope the above information can help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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