PowerShell Genie

Microsoft.Graph module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Connect to Microsoft Graph with explicit scopes, inspect the active context and query only the users, groups or devices your automation needs.

Getting it

Install-PSResource -Name Microsoft.Graph from the PowerShell Gallery, or install only the submodules you need such as Microsoft.Graph.Users to keep import time down.

Examples

1PS> Get-MgUser -Top 10
Show reference output
1 DisplayName UserPrincipalName AccountEnabled
2 ----------- ------------------ --------------
3 Adele Vance adelev@contoso.com True
4 Alex Wilber alexw@contoso.com True
1PS> Get-MgGroup -Top 10
Show reference output
1 DisplayName SecurityEnabled MailEnabled GroupTypes
2 ------------------ --------------- ----------- ----------
3 IT Operations True False {}
4 Microsoft 365 Demo False True {Unified}

What it is for

Use it for any cloud identity task, from user and group inventory through service principal and app registration audits. Find-MgGraphCommand is the practical entry point when you know the Graph endpoint but not the cmdlet name.

Typical tasks

  • Inventory users with account state and creation date
  • Find guest accounts by user type
  • Audit service principals and their credentials
  • List group membership including nested groups
  • Export sign-in logs for a review window
  • Report which users hold a given license

Check the installed version

1PS> Get-Module -ListAvailable Microsoft.Graph | Select-Object Name, Version, Path
2PS> Get-Command -Module Microsoft.Graph

Compare the module path and version with the session used by your scheduled task or automation account. Use it for any cloud identity task, from user and group inventory through service principal and app registration audits. Find-MgGraphCommand is the practical entry point when you know the Graph endpoint but not the cmdlet name.

Primary documentation

Microsoft 365, Entra and Azure documentation

Continue
Genie guideMicrosoft.Graph module: setup and commands

Connect to Microsoft Graph with explicit scopes, inspect the active context and query only the users, groups or devices your automation needs.