-
Notifications
You must be signed in to change notification settings - Fork 234
Fix: Unable to login to GCC High due to Windows WAM not supporting national cloud accounts #1501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -207,7 +207,7 @@ | |
| $ExoUPN = Get-MtExo -Request ConnectionInformation | Select-Object -ExpandProperty UserPrincipalName -First 1 -ErrorAction SilentlyContinue | ||
| if ($ExoUPN) { | ||
| Write-Host "`nAttempting to connect to the Security & Compliance PowerShell using UPN '$ExoUPN' derived from the ExchangeOnline connection." -ForegroundColor Yellow | ||
| Connect-IPPSSession -BypassMailboxAnchoring -UserPrincipalName $ExoUPN -ShowBanner:$false | ||
| Connect-IPPSSession -BypassMailboxAnchoring -UserPrincipalName $ExoUPN -ConnectionUri $Environments[$ExchangeEnvironmentName].ConnectionUri -AzureADAuthorizationEndpointUri $Environments[$ExchangeEnvironmentName].AuthZEndpointUri -ShowBanner:$false | ||
| } else { | ||
| Write-Host "`nFailed to connect to the Security & Compliance PowerShell. Please ensure you are connected to Exchange Online first." -ForegroundColor Red | ||
| } | ||
|
|
@@ -258,6 +258,20 @@ | |
|
|
||
| Write-Verbose "🦒 Connecting to Microsoft Graph with parameters:" | ||
| Write-Verbose ($connectParams | ConvertTo-Json -Depth 5) | ||
|
|
||
| # On Windows, the Microsoft Graph SDK uses Windows Account Manager (WAM) as the authentication broker by default. | ||
| # WAM may not support national cloud accounts (e.g. GCC High, DoD, China) in the account picker. | ||
| # Warn users to use -UseDeviceCode if they encounter authentication issues. | ||
| if ($Environment -ne 'Global' -and ($IsWindows -or $PSVersionTable.PSEdition -eq 'Desktop') -and -not $UseDeviceCode) { | ||
| # Build a suggested retry command using only the non-default parameter values provided by the caller. | ||
| $retryCmd = "Connect-Maester -UseDeviceCode -Environment $Environment" | ||
| if ($AzureEnvironment -ne 'AzureCloud') { $retryCmd += " -AzureEnvironment $AzureEnvironment" } | ||
| if ($ExchangeEnvironmentName -ne 'O365Default') { $retryCmd += " -ExchangeEnvironmentName $ExchangeEnvironmentName" } | ||
| Write-Host "`n💡 Tip: When connecting to the '$Environment' environment on Windows, Windows Account Manager (WAM) may not recognize national cloud accounts in the sign-in prompt." -ForegroundColor Yellow | ||
| Write-Host " If authentication fails or is cancelled, add the -UseDeviceCode parameter to authenticate via browser instead of WAM:`n" -ForegroundColor Yellow | ||
| Write-Host " $retryCmd`n" -ForegroundColor Cyan | ||
| } | ||
|
|
||
| Connect-MgGraph @connectParams | ||
|
|
||
| #ensure TenantId | ||
|
|
@@ -268,6 +282,19 @@ | |
| } catch [Management.Automation.CommandNotFoundException] { | ||
| Write-Host "`nThe Graph PowerShell module is not installed. Please install the module using the following command. For more information see https://learn.microsoft.com/powershell/microsoftgraph/installation" -ForegroundColor Red | ||
| Write-Host "`Install-Module Microsoft.Graph.Authentication -Scope CurrentUser`n" -ForegroundColor Yellow | ||
| } catch { | ||
| # For non-global environments on Windows, WAM (Windows Account Manager) may not support national cloud accounts, | ||
| # causing authentication to fail or be cancelled. Provide actionable guidance to the user. | ||
| if ($Environment -ne 'Global' -and ($IsWindows -or $PSVersionTable.PSEdition -eq 'Desktop') -and -not $UseDeviceCode) { | ||
| $retryCmd = "Connect-Maester -UseDeviceCode -Environment $Environment" | ||
| if ($AzureEnvironment -ne 'AzureCloud') { $retryCmd += " -AzureEnvironment $AzureEnvironment" } | ||
| if ($ExchangeEnvironmentName -ne 'O365Default') { $retryCmd += " -ExchangeEnvironmentName $ExchangeEnvironmentName" } | ||
| Write-Host "`n💡 Authentication failed for the '$Environment' environment on Windows." -ForegroundColor Yellow | ||
| Write-Host " Windows Account Manager (WAM) may not support national cloud accounts in the sign-in prompt." -ForegroundColor Yellow | ||
| Write-Host " Run Connect-Maester with -UseDeviceCode to authenticate via browser instead of WAM:`n" -ForegroundColor Yellow | ||
| Write-Host " $retryCmd`n" -ForegroundColor Cyan | ||
| } | ||
|
Comment on lines
+285
to
+296
|
||
| throw | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested
$retryCmddoesn’t currently include several caller-supplied non-default parameters (e.g.,-TenantId,-GraphClientId,-Service,-SendMail,-SendTeamsMessage,-Privileged,-TeamsEnvironmentName). This can cause the copy/paste “retry” command to change behavior vs the original invocation. Consider generating the retry command from$PSBoundParameters(addingUseDeviceCode=$true, preserving any explicitly provided params, and optionally omitting values that match defaults) so the guidance is accurate and future-proof.