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 Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

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 […]

Leave a Reply

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

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading