M365

Getting started with Microsoft Graph PowerShell

1 min read

On this page

Note

This is a sample post that shows what an article looks like. Replace or delete it when you publish your own.

Most Microsoft 365 administration that goes beyond the admin portals ends up in Microsoft Graph. This post walks through the first steps: installing the module, signing in and reading some data.

Install the module

Open PowerShell and install the module for your own user account:

Install-Module Microsoft.Graph -Scope CurrentUser

Sign in with the right scopes

Graph works with permission scopes. Ask only for what you need for the task at hand:

Connect-MgGraph -Scopes "User.Read.All"

Tip

Run Get-MgContext to see which account and scopes your current session uses.

Run a first query

Get-MgUser -All |
    Select-Object DisplayName, UserPrincipalName |
    Sort-Object DisplayName

Sign out

Disconnect-MgGraph

What the formatting looks like

ElementHow to write it
Code blockThree backticks followed by the language, for example powershell
Note or tipA quote that starts with [!NOTE], [!TIP] or [!WARNING]
ScreenshotPut the image next to index.md and write ![description](file.png)

#PowerShell#Microsoft Graph#Entra ID