Inconsistent Results with Graph API query in Graph Explorer

DISYSadmin 6 Reputation points
2021-04-05T18:24:11.823+00:00

Hello!

I'm trying to craft the perfect query to Microsoft Graph that gives me a list of all users that have not signed in since 30 days ago. (also, I don't want to see disabled accounts.)

So far I've gotten this:

https://graph.microsoft.com/beta/users?$select=displayname,signinactivity&$filter=accountEnabled eq true &signInActivity/lastSignInDateTime le 2021-03-01T00:00:00Z

That output gives me every attribute for the user, and tons of other data I don't need. (Hundreds of lines).
ALSO, it shows me users that have logged in after 2021-03-01. So it doesn't work.

If I change it to:

https://graph.microsoft.com/beta/users?$select=displayname,signinactivity&filter=signInActivity/lastSignInDateTime le 2021-03-01T00:00:00Z&accountEnabled eq true

It shows me too much data (i.e. select doesn't work,) it shows me disabled accounts, and it shows me accounts that logged in recently. I don't even know what it's filtering.

This:

https://graph.microsoft.com/beta/users?$select=signinactivity&filter=signInActivity/lastSignInDateTime le 2021-03-01T00:00:00Z

Gives me almost exactly what I want. It's only showing me signinactivity and it is properly filtering.

https://graph.microsoft.com/beta/users?$select=displayname,signinactivity&filter=signInActivity/lastSignInDateTime le 2021-03-01T00:00:00Z

But if I simply add displayname back into select, now I get 100 lines of data per user again AND the activity filter stops working. The above is almost identical to an example on Microsoft's website!

If my queries are improperly formatted, I would expect to see an error. I'm kind of baffled on this one. Does anyone have some advice?

Thank you!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,683 questions
{count} votes