Mr-Tbone / Intune

Collection of my Intunescripts
22 stars 11 forks source link

Not able to filter with device groups. #10

Open erikeinmo opened 1 month ago

erikeinmo commented 1 month ago

When adding device groups here,

[System.Object]$DeviceGroups = @("groupname") # Group filter. @() = all devices. @("tbone-devices", "tbone-devices2") will filter only members of those groups

The script fails with:

Write-Error: 2024-08-09,10:47:39,Failed to get Device Group Members with error: Cannot convert the "Microsoft.Graph.PowerShell.Models.MicrosoftGraphDevice" value of type "Microsoft.Graph.PowerShell.Models.MicrosoftGraphDevice" to type "System.Collections.ArrayList". Write-Error: 2024-08-09,10:47:40,Failed to get Devices with error: The property 'deviceid' cannot be found on this object. Verify that the property exists.

What could be causing this?

bradywidener commented 2 weeks ago

I'm running into the exact same issue. What is odd is that it only appears to happen when running the script in an Azure Automation Runbook. Whenever I run the same script locally, it works as intended.