Getting details about the current Microsoft Graph PowerShell context is essential for understanding how sessions interact with resources, permissions, and authentication tokens. For IT admins, this can become complex when multiple tenants or identities are in play, or when scripts run across different environments. The upside is there are reliable methods to quickly review, verify, and manage the current Microsoft Graph PowerShell context effectively.
Connect-MgGraph -Scopes "User.Read"
Get-MgContext
The syntax is as follows:
Get-MgContext
Example
Retrieve details of the current Microsoft Graph context, including account, tenant, environment, and granted scopes.
Example query:
Connect-MgGraph -Scopes "User.Read"
Get-MgContext
Example output:
ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
TenantId: 72f988bf-86f1-41af-91ab-2d7cd011db47
Account: john@testdomain.com
Scopes: {User.Read}
AuthType: Delegated
CertificateThumbprint:
AppName: Microsoft Graph PowerShell
ContextType: MicrosoftGraphPowerShell
Environment: Global
This output shows that the user with the ID e9b1f3a1-1234-4d56-9abc-0def12345678, displayed as John, has been assigned the Global Administrator role. The RoleDefinitionId links this assignment to the Global Administrator role definition in the directory. The PrincipalType confirms that the assignment is for a user (not a group or service principal). Finally, the DirectoryScopeId is set to /, which means this role applies to the entire tenant, not just a specific resource or scope.
ADManager Plus helps admins stay on top of Microsoft 365 management with a simple, centralized console.
Create, modify, and manage users, groups, and licenses at scale. Perform bulk updates, adjust memberships, assign or revoke licenses, and keep everyday administrative tasks organized.
Access more than 200 prebuilt reports, including sign-in activity and account status, to monitor user behavior and maintain visibility across your tenant.
Automate user provisioning and deprovisioning with role-based group memberships, license assignments, and account setups. Ensure employees have access from day one and remove access immediately when they leave.
Streamline repetitive tasks such as bulk user changes, license assignments, and group updates. Save time and reduce manual errors with scheduled and event-driven automation.
Distribute responsibilities safely with role-based access delegation. Empower teams to manage day-to-day tasks while retaining oversight and control.
Review the scopes listed in the context to ensure your session has the required permissions to perform the intended Microsoft Graph operations without running into authorization errors.
Leverage the username or service principal assigned in the context for tracking, audit, or conditional logic inside your PowerShell scripts.
Add debugging switches or inspect request logs when calling Microsoft Graph to trace any access or token issues originating from the current context.