GraphAPI – Filter based on ExtensionAttribute

Even though GraphAPI is nice and amaze with the throughput, the filtering part is always looks more complex for me. This is especially when it becomes a complex query. Hence, I thought of sharing my experiments related GraphAPI filtering.

Lets look at the one I choose today. In the event where we have a custom attribute from OnPrem which is getting synchronized to Azure AD – We may need to filter the objects based on the value from custom attribute. Filtering is supported and here is how we do it.

Get-MgUser -Filter "onPremisesExtensionAttributes/ExtensionAttribute1 eq 'Value'" -ConsistencyLevel eventual -Count userCount

Note that ConsistencyLevel and Count is mandatory to get this working. Else, You may get the below error.

Get-MgUser_List: Unsupported or invalid query filter clause specified for property ‘extensionAttribute1’ of resource ‘User’.

Microsoft Reference – https://learn.microsoft.com/en-us/graph/filter-query-parameter

Leave a Reply