Photo by Adam Littman Davis / Unsplash

Connect-MgGraph - Disable WAM (updated December 2, 2026)

Bastien Perez
Bastien Perez
· 3 min read

Table of Contents

No matching heading

⚠️
Be careful: starting with version 2.34.0, WAM becomes the default and Set-MgGraphOption -EnableLoginByWAM $false no longer works. For 2.34.0 and later, use your own app registration, see the section at the end of this article.

Some blogs mention that they get this message when they use Connect-MgGraph with 2.34.0 :
"NOTE: Sign in by Web Account Manager (WAM) is enabled by default on Windows systems and cannot be disabled. Any setting stating otherwise will be ignored."

However, on my side, I only see:
"WARNING: Note: Sign in by Web Account Manager (WAM) is enabled by default on Windows. If using an embedded terminal, the interactive browser window may be hidden behind other windows."

There is no mention that it cannot be disabled (??).

Even without this mention in my version 2.34.0, the cmdlet shown in my post no longer works. I can understand Microsoft’s strategy, but where is the official announcement of this change (a blog or similar)? This is not a minor change.

If you use the Microsoft Graph PowerShell module to manage Microsoft 365 environments, you may have noticed a change in behavior in recent versions regarding authentication.

WAM by default

For several versions now, the Connect-MgGraph cmdlet has been using WAM (Web Account Manager) by default, an authentication system built into Windows that launches an embedded browser with the message

WARNING: Note: Sign in by Web Account Manager (WAM) is enabled by default on Windows. If using an embedded terminal, the interactive browser window may be hidden behind other windows.

While this feature may appear useful in some situations, it introduces several issues in a context involving the management of multiple customers:

  • No automatic filling: Unable to use your password manager to automatically fill in credentials
  • No session reuse: Sessions already active in your main browser are not used
  • Local traces: Your workstation stores information about client connections, which is not ideal from a security and privacy standpoint

For a consultant or an administrator juggling multiple Microsoft 365 tenants, this user experience quickly becomes problematic (at least from my point of view).

The solution: Disable WAM

Fortunately, Microsoft introduced an option to disable this behavior starting with version 2.33.0 of the module.

If you are using version 2.34.0 or later, WAM is now mandatory and this option is ignored. Use your own app registration instead, as described in the next section.

You just need to run the following command:

Set-MgGraphOption -EnableLoginByWAM $false

This option forces the module to use the system’s default browser instead of the embedded WAM browser.

You therefore regain the classic authentication experience with all its advantages.

Version 2.34.0 and later: your own app registration

Since 2.34.0, Set-MgGraphOption -EnableLoginByWAM $false no longer works. Another way out is to sign in with your own app registration instead of the Microsoft Graph Command Line Tools app: a public client app whose redirect URI is http://localhost. The sign-in then opens in your default browser.

The script below creates it once per tenant. It needs an account that can create applications and grant admin consent (Global Administrator, or Application Administrator plus Privileged Role Administrator). Change the app name and the scopes in $scopes to fit your needs. The consent is given for all users of the tenant (AllPrincipals), only for the scopes you list.

# The delegated permissions the app will ask for: adapt them to what you do.
$scopes = @('User.Read.All', 'Group.Read.All')

Connect-MgGraph -Scopes 'Application.ReadWrite.All', 'DelegatedPermissionGrant.ReadWrite.All' -ContextScope Process -NoWelcome
$tenantId   = (Get-MgContext).TenantId
$graphAppId = '00000003-0000-0000-c000-000000000000'

$graph = Invoke-MgGraphRequest -Method GET -Uri "v1.0/servicePrincipals(appId='$graphAppId')"

$access = foreach ($s in $scopes) {
    $id = ($graph.oauth2PermissionScopes | Where-Object value -eq $s).id
    if (-not $id) { Write-Warning "Scope not found: $s"; continue }
    @{ id = $id; type = 'Scope' }
}

$body = @{
    displayName            = 'Microsoft Graph PowerShell (browser sign-in)'
    signInAudience         = 'AzureADMyOrg'
    isFallbackPublicClient = $true
    publicClient           = @{ redirectUris = @('http://localhost') }
    requiredResourceAccess = @(@{ resourceAppId = $graphAppId; resourceAccess = @($access) })
}
$app = Invoke-MgGraphRequest -Method POST -Uri 'v1.0/applications' -Body ($body | ConvertTo-Json -Depth 10) -ContentType 'application/json'

Start-Sleep -Seconds 10

$sp = Invoke-MgGraphRequest -Method POST -Uri 'v1.0/servicePrincipals' -Body (@{ appId = $app.appId } | ConvertTo-Json) -ContentType 'application/json'

$grant = @{ clientId = $sp.id; consentType = 'AllPrincipals'; resourceId = $graph.id; scope = ($scopes -join ' ') }
Invoke-MgGraphRequest -Method POST -Uri 'v1.0/oauth2PermissionGrants' -Body ($grant | ConvertTo-Json) -ContentType 'application/json' | Out-Null

"ClientId: $($app.appId)  TenantId: $tenantId"

The script prints the client ID and the tenant ID. Keep them, then sign in with them:

Disconnect-MgGraph
Connect-MgGraph -ClientId '<client-id>' -TenantId '<tenant-id>' -NoWelcome

Replace <client-id> and <tenant-id> with the values printed by the script. The scopes come from the consent given to the app, so -Scopes is not needed.

Update July 30, 2026: a community project also fixes Connect-MgGraph: https://github.com/ugurkocde/MgGraphCommunity

Microsoft 365PowerShell

Bastien Perez

Microsoft 365 and Active Directory Consultant | 3x MVP Identity and Access & MVP M365 | Clidsys founder

Comments