# Validated on Microsoft.Graph PowerShell SDK v2.29.1
$ErrorActionPreference = 'stop'
$requiredScopes = 'User.Read.All'
$ctx = Get-MgContext
if (-not $ctx -or ($requiredScopes | Where-Object { $ctx.Scopes -notcontains $_ })) {
Connect-MgGraph -Scopes $requiredScopes -NoWelcome
}
$users = Get-MgUser -All -PageSize 999 -Filter "userType eq 'Member'"