Hi everyone,
I am trying to get a device by the deviceId, not by the objectId via the AzureAd PowerShell. Reason is simple: I don't have the objectId, I only have the deviceId. I tried it with:
Get-AzureADDevice -Filter "deviceId eq 'device-id-example-000-123456'"
But I got that error:
Get-AzureADDevice : Error occurred while executing GetDevices Code: Request_BadRequest Message: A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'.
Ok, I thought I should cast the deviceId to string, but:
Get-AzureADDevice -Filter "cast(deviceId, Edm.String) eq 'device-id-example-000-123456'" Get-AzureADDevice : Error occurred while executing GetDevices Code: Request_BadRequest Message: The child type 'Edm.String' in a cast was not an entity type. Casts can only be performed on entity types
I am not very familliar with OData queries, so is there a way to build the filter that I can get a device with the deviceId? And I want to use the OData filter unless the OData implentation simply doesn't allow it.
I am aware that a workaround would be to simply use a where clause:
Get-AzureAdDevice -All:$true | where {$_.DeviceID -eq "device-id-example-000-123456"}
But this way it is super slow, if I have to work with a list of device IDs. Of course there is another way to handle this, getting all devices into an array and then search through the array, but that is another workaround.
So if anyone can help me with the correct OData syntax it would be highly appreciated.
Thank you very much!