[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.
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.
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?