Two Azure Domain, how to switch account when generating a report via powershell?

JYLVEN TARRAJA 20 Reputation points
2025-01-24T02:13:58.1833333+00:00

Please help me on this.

Two azure domain, want to generate a report using a powershell unable to switch account for the other domain.

How to switch account to other azure domain when generating a report via powershell.

Thank you

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,609 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,759 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,010 questions
Microsoft Power Platform Training
Microsoft Power Platform Training
Microsoft Power Platform: An integrated set of Microsoft business intelligence services.Training: Instruction to develop new skills.
559 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kavya 315 Reputation points
    2025-01-24T08:18:55.06+00:00

    You can create a Graph session using Tenant ID, for example

    Connect-MgGraph -TenantId <tenantId>.

    After generating report run the Disconnect-MgGraph to disconnect existing session. In this way, you can switch between tenants without any issues.


1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2025-01-24T02:13:58.23+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To switch accounts between two Azure domains when generating a report using PowerShell, you need to ensure that you are authenticated with the correct Azure Active Directory (AAD) tenant. Here are the steps you can follow:

    1. Sign in to the Azure portal using the account that has access to the desired domain.
    2. Select the subscription you want to use from the Subscriptions page in the Azure portal.
    3. Change the directory by selecting the "Change Directory" option. This will allow you to switch to the other Azure domain.
    4. After switching, you can use PowerShell commands to generate your report. Make sure to authenticate again if necessary, using the Connect-AzAccount command with the appropriate parameters for the new domain.

    If you encounter issues with permissions, ensure that your account has the necessary roles assigned in the target Azure domain.


    References:


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.