How to use connect-azaccount cmdlet to connect to multiple tenants

Muhammad Suhail Asrulsani 6 Reputation points
2021-11-15T15:24:23.47+00:00

Hi

I want to loop Connect-AzAccount cmdlet to a multiple tenant without prompting for password and MFA.

When connecting to my own tenant, I can connect using below command.

Connect-AzAccount  -ServicePrincipal -ApplicationId $ApplicationId -Tenant $TenantID -CertificateThumbprint $ThumbprintID

It is not working when trying to connect to different tenant. Please advise

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,812 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 39,371 Reputation points
    2021-12-16T18:23:27.617+00:00

    You can consult the article that talks about "Connect-AzAccount" and the different ways to use it, I believe that what you are looking for is in this article and should help you enough to proceed:

    https://learn.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-6.6.0

    ----

    --If the answer is helpful, please vote positively and accept the answer--

    0 comments No comments

  2. Murugesa Pandian 86 Reputation points
    2021-12-19T04:09:27.407+00:00

    Hi,

    You can switch back and forth by changing the tenant id using Connect-AzAccount -Tenant $tenantid.
    There is no option to log into multiple tenant accounts simultaneously using the above cmdlet.

    0 comments No comments