Graph

Entra ID & Graph – Part 1 – User Objects

In the last few years, Graph started to dominate on accessing/managing various products across Microsoft cloud platforms. We are starting with a series of posts related with Graph API and various techniques for IT Administrators, which could be helpful on the day today operations.

Filtering User Objects

Filter based on DisplayName
Get-MgUser -Filter “Displayname eq ‘Abba'”

Filter based on Email address
Get-MgUser -Filter “mail eq ‘thomas@decodingcloud.in'”

Filter based on starting pattern
Get-MgUser -Filter “StartsWith(DisplayName,’ab’)”

Filter based on an attribute not equal to a specific value
Get-MgUser -Filter “displayname ne ‘abba'” -ConsistencyLevel eventual -CountVariable CountVa
Note – The operator ‘ne’ falls under Advanced Query, Hence ConsistencyLevel and CountVariable are required.

Note – Note all properties are supported for advanced queries. Refer the official documentation for understanding the supported attributes.

Filter based on an attribute ending with a specific value
Get-MgUser -Filter “endswith(UserPrincipalName,’decodingcloud.in’)” -ConsistencyLevel eventual -CountVariable Count

Note – Note all properties are supported for advanced queries. Refer the official documentation for understanding the supported attributes.

These MG cmdlets are to read objects based on certain conditions from Entra ID. I have included sample queries which are available by default and advanced queries which needs additional consideration. The thumb rule to understand is for query operations, It depends on

1) Understanding if the operator supports filtering based on the specific property we are trying to filter
2) Understanding if the filtering falls under an advanced filtering capability

And for Entra ID, this changes based on each object category.

Lets discuss more on advanced queries on the next blog post.


Posted by Shabarinath in Graph, 0 comments

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

Posted by Shabarinath in Graph, 0 comments