Build ready-to-run Microsoft Graph PowerShell commands for Entra ID users, groups, MFA, licensing, roles, devices and audit logs. Free, no sign-in.
This tool builds ready-to-run PowerShell for Microsoft Entra ID (still widely searched for as “Azure AD”). Pick a task — create a user, reset a password, audit MFA registration, list unused licences, dump sign-in logs — fill in the one or two values it needs, and copy a command that works as-is. It also tells you which Microsoft Graph permission scopes that command requires, which is the single most common reason a copied snippet fails with Insufficient privileges.
Everything runs in your browser. Nothing you type is sent anywhere, and no tenant is contacted — the tool generates text, it does not execute anything. That means you can safely paste a real UPN or tenant ID into the fields to get a command you can run without editing.
If you are following an older blog post, the commands in it are probably dead. The AzureAD and MSOnline PowerShell modules were retired on 30 March 2025. Cmdlets such as Connect-AzureAD, Get-AzureADUser, Set-AzureADUser and Get-MsolUser no longer have a supported service behind them. The replacement is the Microsoft Graph PowerShell SDK, whose cmdlets all carry an Mg noun prefix: Get-MgUser, New-MgGroup, Get-MgAuditLogSignIn, and so on.
This tool has a Graph / legacy toggle. Graph is the default and is what you should copy. The legacy view exists purely so you can recognise an old script and find its modern equivalent side by side — every legacy snippet is labelled as deprecated. Use it as a translation table when you inherit a scripts folder nobody has touched since 2021.
Tasks are grouped into eight tabs:
Connect-MgGraph rather than requesting everything.Install the SDK once, from an elevated or user-scoped PowerShell session:
Install-Module Microsoft.Graph -Scope CurrentUser -Repository PSGallery -Force
PowerShell 7 or later is recommended on every platform; Windows PowerShell 5.1 works but needs .NET Framework 4.7.2 and an execution policy of RemoteSigned or looser. Installing the umbrella Microsoft.Graph module pulls in dozens of sub-modules, so on a constrained build agent you may prefer to install only the sub-modules you need — Microsoft.Graph.Authentication always comes along.
Then authenticate. Interactive sign-in is the normal path for ad-hoc administration:
Connect-MgGraph -Scopes "User.Read.All", "Group.Read.All"
On a server or SSH session with no browser, use device code flow, which prints a code you enter on another machine:
Connect-MgGraph -Scopes "User.Read.All" -UseDeviceCode
For scheduled and unattended work, register an application, upload a certificate, grant application permissions with admin consent, and connect with no human in the loop:
Connect-MgGraph -TenantId <tenant-id> -ClientId <app-id> -CertificateThumbprint <thumbprint>
Get-MgContext shows who you are signed in as and which scopes were actually granted — run it first whenever a command returns a permissions error. Finish with Disconnect-MgGraph, particularly on shared jump boxes.
| Retired (AzureAD / MSOnline) | Microsoft Graph PowerShell |
|---|---|
Connect-AzureAD | Connect-MgGraph -Scopes ... |
Get-AzureADUser -ObjectId | Get-MgUser -UserId |
New-AzureADUser | New-MgUser |
Set-AzureADUser -AccountEnabled $false | Update-MgUser -AccountEnabled:$false |
Remove-AzureADUser | Remove-MgUser |
Get-AzureADGroup | Get-MgGroup |
Get-AzureADUserMembership | Get-MgUserMemberOf |
Disconnect-AzureAD | Disconnect-MgGraph |
Paging. Graph returns 100 objects per page by default. Get-MgUser on its own does not return your whole tenant — add -All. Forgetting this produces reports that quietly under-count.
Property selection. Many attributes are not returned unless you ask. If a property comes back empty when you know it has a value, add it to -Property and then select it in the pipeline.
Advanced queries. Filters on some properties require the ConsistencyLevel header and a count — the error message when you omit it is unhelpfully generic.
Scopes are cumulative per session. Connecting with a narrow scope set and then running a command needing more does not silently escalate; you must reconnect requesting the additional scope.
Delegated versus application permissions. An interactive session is limited by both the granted scope and your own role. A command that works for a Global Administrator interactively can still fail under a service principal that was granted only delegated consent.
If you administer the wider Microsoft stack, the same command-builder pattern is available for Exchange Online PowerShell, Windows Update PowerShell, and Group Policy commands. When a task involves setting a temporary password, generate it with the secure password generator rather than reusing a pattern across accounts.
No. The AzureAD and MSOnline modules were retired on 30 March 2025. Scripts built on them should be migrated to the Microsoft Graph PowerShell SDK. This tool shows legacy cmdlets only for reference, clearly labelled as deprecated, so you can map an old script to its replacement.
Run Install-Module Microsoft.Graph -Scope CurrentUser -Repository PSGallery -Force. Verify with Get-InstalledModule Microsoft.Graph and keep it current with Update-Module Microsoft.Graph.
The scopes granted to your session do not cover the call. Check what you actually have with Get-MgContext, then reconnect with the scopes this tool lists for that task. If you are using app-only auth, the application permission also needs admin consent in the tenant.
Use device code flow: Connect-MgGraph -Scopes "User.Read.All" -UseDeviceCode. PowerShell prints a URL and a code that you enter from any other device. For fully unattended jobs, use certificate-based app-only authentication instead.
Yes — the MFA & Auth tab builds a command around Get-MgUserAuthenticationMethod that enumerates each user’s registered methods. Accounts whose only method is a password are the ones to chase.
No. It generates text in your browser and never contacts Microsoft or any server of ours. Values you type stay on your machine. You run the copied command yourself, in your own session, so you keep full control over what executes.
Graph pages results. Add -All to the cmdlet to retrieve every object rather than the first page.
Yes. Azure Active Directory was renamed Microsoft Entra ID; the directory, the objects and the Graph API are the same. The old name survives in search habits, documentation and countless scripts, which is why this page uses both.
Azure Active Directory (now Microsoft Entra ID) PowerShell modules enable administrators to manage identity, access, and directory services programmatically. Instead of clicking through the Azure portal for each user, group, or policy change, PowerShell commands allow bulk operations, automation, and scripted management of cloud identities at enterprise scale.
Two primary modules exist: the older MSOnline (MSOL) module and the newer Microsoft Graph PowerShell SDK. Microsoft is deprecating MSOL in favor of the Graph SDK, making it essential for administrators to understand both modules during the transition period.
| Feature | MSOnline (MSOL) | AzureAD Module | Microsoft Graph PowerShell |
|---|---|---|---|
| Status | Deprecated (March 2024) | Deprecated | Current / Recommended |
| Authentication | Basic + MFA | Basic + MFA | Modern auth, certificate, managed identity |
| Scope | Azure AD only | Azure AD only | All Microsoft 365 services |
| Command prefix | Msol- | AzureAD- | Mg- |
| Install | Install-Module MSOnline | Install-Module AzureAD | Install-Module Microsoft.Graph |
The AzureAD and MSOnline modules were deprecated and retired by Microsoft on March 30, 2025. The Microsoft Graph PowerShell SDK is the supported replacement, built on the Microsoft Graph API, and receives all new features and security fixes. This builder generates Graph commands by default and only shows the old AzureAD/MSOnline equivalents as a secondary reference where they still function.
Install the SDK for your account with Install-Module Microsoft.Graph -Scope CurrentUser -Force (no admin rights needed). Then connect with Connect-MgGraph -Scopes "User.Read.All" (or whichever scopes your task needs). On a headless server use -UseDeviceCode, and for unattended automation use app-only auth with -ClientId and -CertificateThumbprint. Run Disconnect-MgGraph when finished.
Scopes are the delegated permissions you grant to a Connect-MgGraph session. Requesting the minimum needed (for example User.Read.All for a read instead of Directory.ReadWrite.All) follows least-privilege and reduces risk if the session is compromised. This tool sets the smallest scope set for each task automatically and shows it above the generated script, along with the Entra role required to run it.
Use Get-MgUserAuthenticationMethod -UserId user@contoso.com to list the authentication methods registered for a user. The builder's "List users without MFA registered" task loops every user and flags anyone whose only method is the password, and the "Per-user MFA method report" task builds a full export. Both need the UserAuthenticationMethod.Read.All scope.
A usage location must be set first: Update-MgUser -UserId user@contoso.com -UsageLocation "US". Then resolve the SKU ID from its part number with Get-MgSubscribedSku and call Set-MgUserLicense -UserId user@contoso.com -AddLicenses @{ SkuId = $skuId } -RemoveLicenses @(). To remove, pass the SKU ID in -RemoveLicenses instead. The License Administrator role is required.
The SignInActivity property (used by the last sign-in and inactive-user reports) requires an Entra ID P1 or P2 license and the AuditLog.Read.All scope. Without both, the field returns null for every user. Connect with Connect-MgGraph -Scopes "AuditLog.Read.All","User.Read.All" and confirm the tenant has the right licensing.
Block sign-in with Update-MgUser -UserId user@contoso.com -AccountEnabled:$false, then immediately revoke active tokens with Revoke-MgUserSignInSession -UserId user@contoso.com so existing sessions are signed out. The builder's "Disable an account" task generates both steps. Deleting a user (Remove-MgUser) is a soft delete; the account stays restorable for 30 days.
Yes. Reporting, licensing, group, MFA, and device tasks expose an optional CSV export path field. When you fill it in, the generated script pipes the results to Export-Csv -Path "C:\Reports\report.csv" -NoTypeInformation -Encoding UTF8 instead of formatting to the console, so you can open the output in Excel or hand it to compliance.