Microsoft Graph – Frequently used Graph API Queries for Users – Part 1

fig : Microsoft Graph - API permissions required to execute the user counts and user listing queries
fig : Microsoft Graph - API permissions required to execute the user counts and user listing queries

Hi All,

Greetings for the day!!!

I am compiling frequently used Microsoft Graph APIs. In this series of articles today we are listing all queries related to users count and users listing. All these queries are “Get

Also explore different parameters to Graph queries like – Filter, Search, OrderBy, Select

Following API permissions will require to execute / use following queries

fig : Microsoft Graph - API permissions required to execute the user counts and user listing queries
fig : Microsoft Graph – API permissions required to execute the user counts and user listing queries

Queries related Users count in tenant

  • Get all users count from my tenant including guest users
    • Method : GET
https://graph.microsoft.com/v1.0/users/$count

  • Get all users count from my tenant except guest users
    • Method : GET
    • Details :
      • We could have filter based on “userType” property
      • For guest users “userType” is “guest
https://graph.microsoft.com/v1.0/users/$count?$filter=userType ne 'guest'

  • Get all guest users count from my tenant
    • Method : GET
https://graph.microsoft.com/v1.0/users/$count?$filter=userType eq 'guest'

Listing of Users

  • Get all users from my tenant
    • Method : GET
https://graph.microsoft.com/v1.0/users

  • Get all users from my tenant except guest users
    • Method : GET
https://graph.microsoft.com/v1.0/users/?$filter=userType ne 'guest'

  • Get all guest users from my tenant
    • Method : GET
https://graph.microsoft.com/v1.0/users/?$filter=userType eq 'guest'

  • Get all users with sort by / order by display name property
    • Method : GET
https://graph.microsoft.com/v1.0/users?$count=true&$orderBy=displayName

fig : Microsoft Graph - All users from my tenant along with count and order by - Display Name
fig : Microsoft Graph – All users from my tenant along with count and order by – Display Name

  • Get all users with selected properties
    • Method : GET
https://graph.microsoft.com/v1.0/users?$select=id,displayName,mail,userPrincipalName

fig : Microsoft Graph - All users from my tenant with selected properties only
fig : Microsoft Graph – All users from my tenant with selected properties only

  • Get all users of my tenant with filter based on properties – here we will filter “department” property
    • Method : GET
https://graph.microsoft.com/v1.0/users?$count=true&$filter=Department eq 'IT'

fig : Microsoft Graph – All users from my tenant from IT department
  • Users with containing value in specific property – here for example – we will find all users whose display name contains “knowledge”
    • Method : GET
https://graph.microsoft.com/v1.0/users?$search="displayName:knowledge"

fig : Microsoft Graph - All users from my tenant whose display name contains "knowledge" - using search parameter
fig : Microsoft Graph – All users from my tenant whose display name contains “knowledge” – using search parameter

Thanks for reading !!! If its worth at least reading once, kindly please like and share !! SHARING IS CARING 🙂

Enjoy the beautiful life !!! Have a FUN !!! TAKE CARE 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

1 Response

  1. December 12, 2022

    […] In last article we discussed – listing all queries related to users count and users listing. All these queries are “Get” – Microsoft Graph – Frequently used Graph API Queries for Users – Part 1 […]

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: