Find Cloud-Only Users with Microsoft Graph PowerShell

Learn how to identify cloud-only users in Microsoft Entra ID using Microsoft Graph PowerShell.

# 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
}

$params = @{ 
    'All'              = $true
    'PageSize'         = '999'
    'Filter'           = "onPremisesSyncEnabled ne true and userType eq 'member'"
    'ConsistencyLevel' = 'eventual'
    'CountVariable'    = 'userCount'
}

$users = Get-MgUser @params
Loading...