Connect-AzAccount -Tenant <ID> connects with wrong account
Description
Hi
I have two tenants, if I try to connect to each other with each other's accounts, I don't get an error... it seems to tell me it is all fine. I expect it to say "this account doesn't belong to this tenant, bugger off"
This is what I'm doing.
Disconnect-AzAccount
Clear-AzContext -Scope CurrentUser -Force
Connect-AzAccount -Tenant $tenant2 -WarningAction SilentlyContinue
When I'm prompted, I choose the wrong credentials. Then I get this
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
[email protected] <ID for Tenant2> AzureCloud
I don't expect this to succeed, I was hoping for an error that I can capture and ask the user to reauthenticate with correct credentials.
Am I doing something wrong? I only have this problem with native accounts.
Thanks
Script or Debug output
No response
Environment data
Name Value
---- -----
PSVersion 5.1.19041.1320
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.1320
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
2.6.2
Error output
No response
Thanks for contacting us.
Empty subscription is one valid case in special scenario. The latest Connect-AzAccount allows user to specify account id. Could you append -AccountId when you use Connect-AzAccount?
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!