microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
696 stars 168 forks source link

Get-MgDeviceManagementWindowAutopilotDeviceIdentity -filter by Id/SerialNumber returns InvalidOperation #1260

Closed dandirk closed 2 years ago

dandirk commented 2 years ago

Haven't been able to get -filter to work for Get-MgDeviceManagementWindowAutopilotDeviceIdentity. Tried Id and SerialNumber properties. Tried latest module version.

-WindowsAutopilotDeviceIdentityId works, but -filter "Id eq 'SAME_ID'" returns same error as other properties like serialnumber.

Get-MgDeviceManagementWindowAutopilotDeviceIdentity -filter "SerialNumber eq '5CGxxxxx'"

ErrorDetails.Message { "_version": 3, "Message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: d17f5918-d7ad-4cfe-91b1-xxxxxx - Url: https://fef.msua02.manage.microsoft.com/DeviceEnrollmentFE_2204/StatelessDeviceEnrollmentFEService/deviceManagement/windowsAutopilotDeviceIdentities?api-version=5022-03-28&$filter=serialNumber+eq+%275CGxxxxx%27", "CustomApiErrorPhrase": "", "RetryAfter": null, "ErrorSourceService": "", "HttpHeaders": "{}" }

CategoryInfo Category : InvalidOperation Activity : Get-MgDeviceManagementWindowAutopilotDeviceIdentity_List1 Reason : RestException1 TargetName : { Top = , Skip = , Search = , Filter = SerialNumber eq '5CGxxxxx', Count = , Sort = , Property = , ExpandProperty = } TargetType : <>f__AnonymousType28

peombwa commented 2 years ago

@dandirk, please see the answer at https://docs.microsoft.com/en-us/answers/questions/339746/filtering-doesnt-seem-to-work-on-a-newer-intuneap.html.

In PowerShell, this will be:

Get-MgDeviceManagementWindowAutopilotDeviceIdentity -Filter "contains(serialNumber,'011138765157')" -Debug

Microsoft Graph Q&A is good starting point for service related issues - https://developer.microsoft.com/en-us/graph/support.

dandirk commented 2 years ago

Thanks @peombwa obviously my google-fu failed in this scenarios... That worked for serialnumber

Interestingly SerialNumber works but Id doesn't... (though if you have the ID probably should use the properly cmd).

peombwa commented 2 years ago

@dandirk, you are right. Ids are not filterable since you can use Get-MgDeviceManagementWindowAutopilotDeviceIdentity -WindowsAutopilotDeviceIdentityId "ID".