Quick answer: Get-MgBetaUser reads users from the Microsoft Graph beta endpoint. Install Microsoft.Graph.Beta, run Connect-MgGraph -Scopes 'User.Read.All', then run Get-MgBetaUser -All to list every user or Get-MgBetaUser -UserId <id or UPN> for one. For scripts you run in production, Microsoft recommends the v1.0 cmdlet, Get-MgUser, because beta APIs can change without notice.
Get-MgBetaUser vs Get-MgUser
Both cmdlets call the same "list users" and "get user" operations in Microsoft Graph. The difference is the endpoint.
| Get-MgUser | Get-MgBetaUser | |
|---|---|---|
| Module | Microsoft.Graph.Users | Microsoft.Graph.Beta.Users |
| Install | Install-Module Microsoft.Graph |
Install-Module Microsoft.Graph.Beta |
| Endpoint | graph.microsoft.com/v1.0 |
graph.microsoft.com/beta |
| Production use | Supported | Not supported by Microsoft |
Microsoft's Graph docs say APIs under /beta "are subject to change" and that using them in production applications is not supported. Use Get-MgBetaUser when you need a property or behavior that only exists in beta, and check the version selector on Learn first to see whether v1.0 already has it.
Every beta cmdlet follows the same naming pattern: Mg becomes MgBeta. Get-MgGroup becomes Get-MgBetaGroup, Get-MgApplication becomes Get-MgBetaApplication, and so on.
Install the beta module
The beta SDK is a separate module from the v1.0 SDK. You can install both in the same PowerShell version, and each one calls its own endpoint.
# Beta module (includes Microsoft.Graph.Beta.Users)
Install-Module Microsoft.Graph.Beta -Repository PSGallery -Force
# v1.0 module, if you also want Get-MgUser
Install-Module Microsoft.Graph -Scope CurrentUser -Repository PSGallery -Force
Microsoft recommends PowerShell 7 or later. Windows PowerShell 5.1 works if you have .NET Framework 4.7.2 or later and an up-to-date PowerShellGet. Installing in PowerShell 7 doesn't install it for Windows PowerShell, so run the command in the version you plan to use.
Permissions
Get-MgBetaUser needs one of these Graph permissions. They're listed from least to most privileged.
| Permission type | Least privileged | Higher privileged |
|---|---|---|
| Delegated (work or school account) | User.ReadBasic.All | User.Read.All, User.ReadWrite.All, Directory.Read.All, Directory.ReadWrite.All |
| Application | User.Read.All | User.ReadWrite.All, Directory.Read.All, Directory.ReadWrite.All |
User.ReadBasic.All only returns a basic set of properties. Ask for User.Read.All if you need anything more. Guest users can't call the list operation.
Connect-MgGraph -Scopes 'User.Read.All'
For unattended scripts, connect with an app registration and certificate instead. The Connect-MgGraph guide covers both methods.
Syntax
Get-MgBetaUser has 3 parameter sets. The proxy and debugging parameters are left out here.
# List (default)
Get-MgBetaUser
[-ExpandProperty <String[]>]
[-Property <String[]>]
[-Filter <String>]
[-Search <String>]
[-Sort <String[]>]
[-Top <Int32>]
[-ConsistencyLevel <String>]
[-PageSize <Int32>]
[-All]
[-CountVariable <String>]
[-Headers <IDictionary>]
[-ResponseHeadersVariable <String>]
[<CommonParameters>]
# Get one user
Get-MgBetaUser
-UserId <String>
[-ExpandProperty <String[]>]
[-Property <String[]>]
[<CommonParameters>]
# Get one user from a piped identity object
Get-MgBetaUser
-InputObject <IUsersIdentity>
[-ExpandProperty <String[]>]
[-Property <String[]>]
[<CommonParameters>]
Parameters
| Parameter | Alias | What it does |
|---|---|---|
-UserId |
The user's object ID or user principal name. Required in the Get set. | |
-All |
Returns every page of results. Without it you get the first page only. | |
-Filter |
An OData filter, such as "accountEnabled eq false". |
|
-Search |
A search phrase in the form '"property:value"'. Needs -ConsistencyLevel eventual. |
|
-Property |
-Select |
The properties to return. Use it to get properties that aren't returned by default. |
-ExpandProperty |
-Expand |
Expands a related entity, such as manager. |
-Sort |
-OrderBy |
Orders results by a property. |
-Top |
-Limit |
Returns only the first n items. |
-PageSize |
Sets the page size. Graph defaults to 100 and allows up to 999. | |
-ConsistencyLevel |
Set to eventual for advanced queries. |
|
-CountVariable |
-CV |
Saves the total count of matching items to a variable. |
-Filter, -Search, -Sort, -Top, -All, -PageSize, -ConsistencyLevel and -CountVariable only work when listing users. They aren't part of the -UserId parameter set.
Examples
1. List all users
Connect-MgGraph -Scopes 'User.Read.All'
Get-MgBetaUser -All | Format-List Id, DisplayName, Mail, UserPrincipalName
2. Get one user by ID or UPN
Get-MgBetaUser -UserId 'e4e2b110-8d4f-434f-a990-7cd63e23aed6' |
Format-List Id, DisplayName, Mail, UserPrincipalName
Get-MgBetaUser -UserId 'adele.vance@contoso.com'
3. Count all users
Get-MgBetaUser -ConsistencyLevel eventual -CountVariable userCount -Top 1 | Out-Null
$userCount
Counting is an advanced query. It needs -ConsistencyLevel eventual. The count lands in $userCount, so you don't need to download every user to get the number.
4. Filter by display name
Get-MgBetaUser -ConsistencyLevel eventual -CountVariable userCount `
-Filter "startsWith(DisplayName, 'Conf')" -Sort UserPrincipalName -All
This returns every user whose display name starts with "Conf", sorted by UPN. Sorting combined with a filter is an advanced query, so it needs -ConsistencyLevel eventual and a count.
5. Search for users
Get-MgBetaUser -ConsistencyLevel eventual -CountVariable userCount `
-Search '"DisplayName:Conf"'
-Search matches any word in the display name that starts with "Conf". startsWith only checks the start of the whole name. Keep the double quotes inside the single quotes. Graph returns an error if you leave out -ConsistencyLevel eventual.
6. Find disabled accounts
Get-MgBetaUser -Filter "accountEnabled eq false" -All `
-Property Id, DisplayName, UserPrincipalName, AccountEnabled |
Select-Object DisplayName, UserPrincipalName
Name AccountEnabled in -Property. If you only filter on it, the column can come back empty in the output.
7. Return properties that aren't returned by default
Get-MgBetaUser -UserId 'adele.vance@contoso.com' `
-Property DisplayName, Department, JobTitle, LastPasswordChangeDateTime |
Format-List DisplayName, Department, JobTitle, LastPasswordChangeDateTime
Graph only returns a common subset of user properties unless you ask for more. If a property shows as empty, add it to -Property before assuming it's blank in the directory.
8. Get a user's manager
$user = Get-MgBetaUser -UserId 'adele.vance@contoso.com' -ExpandProperty manager
$user.Manager.AdditionalProperties['displayName']
9. Export users to CSV
Get-MgBetaUser -All -PageSize 999 `
-Property DisplayName, UserPrincipalName, Mail, Department, AccountEnabled |
Select-Object DisplayName, UserPrincipalName, Mail, Department, AccountEnabled |
Export-Csv -Path .\users.csv -NoTypeInformation
A page size of 999 cuts the number of round trips on large tenants. If you select or filter on signInActivity, the maximum page size drops to 500. For sign-in data, the Get-MgAuditLogSignIn guide is usually the better tool.
Troubleshooting
"The term 'Get-MgBetaUser' is not recognized." The beta module isn't installed in this PowerShell version. Run Install-Module Microsoft.Graph.Beta, then Import-Module Microsoft.Graph.Beta.Users.
"Insufficient privileges to complete the operation." The session's scopes don't cover what you asked for. Disconnect, then reconnect with Connect-MgGraph -Scopes 'User.Read.All' and consent when prompted.
Properties come back empty. They aren't returned by default. Add them to -Property.
"Request_UnsupportedQuery" with -Search, -Sort or a count. These are advanced queries. Add -ConsistencyLevel eventual and -CountVariable.
Only 100 users come back. That's the default page size. Add -All.
-Count from Learn's examples fails. The syntax names the parameter -CountVariable (alias -CV). Use one of those.
FAQ
Should I use Get-MgBetaUser or Get-MgUser?
Use Get-MgUser unless you need something that only exists in beta. Microsoft doesn't support beta APIs in production, and they can change without notice.
Can I install the beta and v1.0 modules side by side?
Yes. Microsoft.Graph and Microsoft.Graph.Beta install separately and can live in the same PowerShell version. Cmdlet names don't collide because every beta cmdlet has MgBeta in its name.
Does Get-MgBetaUser support -Skip?
No. The list users API doesn't support $skip. Use -All or -PageSize to page through results.
Which permission is enough just to read names and emails?
User.ReadBasic.All in delegated mode. It returns a basic set of properties. Application permissions start at User.Read.All.
How do I get group memberships for a user?
Use Get-MgBetaUserMemberOf -UserId <id>, or work from the group side with Get-MgGroupMember.