Microsoft Graph PowerShell
The Microsoft Graph PowerShell SDK: users, groups, licenses and the rest of Microsoft 365 through Graph.
Official documentation- Authentication needed. Please call Connect-MgGraph.Microsoft Graph PowerShell cmdlets such as Get-MgUser print this when the session has no Graph context. Run Connect-MgGraph with the scopes you need, retry.
- Import-Module : Function cannot be created because function capacity 4096 has been exceeded for this scopeWindows PowerShell 5.1 allows 4096 functions per scope and Import-Module Microsoft.Graph exceeds it. Import only needed submodules or raise the limit.
- Get-MgUser : Parameter set cannot be resolved using the specified named parameters.Get-MgUser has separate List and Get parameter sets: -UserId cannot be combined with -Filter, -Search, -All or -Top. Use -UserId alone, or -Filter alone.
- Microsoft Graph PowerShell: Insufficient privileges to complete the operation (Authorization_RequestDenied)Graph returned 403: the token lacks the permission the call needs, or the user lacks the Entra role. Reconnect with the right -Scopes or grant the app role.
- Connect-MgGraph -Scopes: which permissions to request in Microsoft Graph PowerShellConnect-MgGraph -Scopes requests delegated Graph permissions such as User.Read.All. Find the scope a cmdlet needs with Find-MgGraphCommand; app-only differs.
- Get-MgContext: check the Microsoft Graph PowerShell connection, account, tenant and scopesGet-MgContext shows the account, tenant, auth type and scopes of the current Microsoft Graph PowerShell session, and returns nothing when you are not connected.
- New-MgUser -PasswordProfile: create a Microsoft Entra user with PowerShellNew-MgUser needs DisplayName, MailNickname, UserPrincipalName, -AccountEnabled and a -PasswordProfile hashtable with Password and ForceChangePasswordNextSignIn.
- Set-MgUserLicense: assign or remove Microsoft 365 licenses with Microsoft Graph PowerShellSet-MgUserLicense -UserId -AddLicenses @{SkuId=...} -RemoveLicenses @() assigns a license. Get SKU IDs from Get-MgSubscribedSku; set UsageLocation first.
- Connect-MgGraph -NoWelcome: hide the Welcome to Microsoft Graph! messageConnect-MgGraph -NoWelcome suppresses the Welcome to Microsoft Graph! message in scripts. A switch in every parameter set; check the session with Get-MgContext.
- Get-MgUser -All: return every user, not just the first 100Get-MgUser returns only the first page of 100 users unless you add -All. -Top and -PageSize compared, the List parameter set and the errors you can get.
- Get-MgUser -ConsistencyLevel eventual: advanced filters, -Search and -CountVariableendsWith, ne, not and -Search on users need -ConsistencyLevel eventual plus a count variable in Get-MgUser. Without them Graph returns Request_UnsupportedQuery.
- Get-MgUser -Property: why properties are empty and how to select themGet-MgUser returns a small default property set; AccountEnabled, Department or UsageLocation stay empty until requested with -Property (alias -Select).