How would you go about trying to filter out Guest users in a Microsoft Graph query?
In the past, the ne
comparison operator was not supported on the userType
property of the user resource. This made it difficult to query all users that are NOT userType
of 'guest'. There was a way that in most scenarios would return only non-guest users, but wasn't always reliable.
However, as of sometime around June 2021, the userType
property now supports the ne
comparison operator!
So you can now get users that are not guest users with this query: https://graph.microsoft.com/v1.0/users/?$filter=userType ne 'guest'&$count=true
Here is a link to Microsoft Graph Explorer where you can try this query
Important note:
This is an advanced query, so it requires two specific things that have to be set.
- The
ConsistencyLevel
header toeventual
- The
$count=true
query parameter
If those two aren't set, you query will return an error.
Hopefully you've found this useful! Until next time! Peace