Use Get-AzContext to inspect the account, tenant and subscription selected by the Azure PowerShell Az module. A saved context alone does not prove that a new authenticated request will succeed.
Inspect the current context
$context = Get-AzContext
$context | Select-Object Account, Tenant, SubscriptionIf no context appears, connect with Connect-AzAccount. If the command itself is missing, first check whether the Az.Accounts module is available.
Check token acquisition without displaying a token
try {
$null = Get-AzAccessToken -ErrorAction Stop
"Token acquisition succeeded"
} catch {
"Could not acquire a token; check sign-in, tenant and network access."
}This discards the returned token object. Do not copy access tokens into logs or screenshots. Failure can have several causes; reconnect if authentication is required and verify the intended tenant. Successfully obtaining a token does not prove permission to access every Azure resource.
Check which tool you are using
Get-AzContext belongs to Azure PowerShell. The az executable belongs to Azure CLI; logging in with one tool is not the same as selecting a context in the other. For scripts that run unattended, configure the appropriate workload identity rather than adding an interactive login prompt to every run.
To inspect errors before the window disappears, run the script in an existing PowerShell session.
Sources and verification
Checked against the Az.Accounts documentation. No Azure account authentication or resource access was performed for this revision.