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.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
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.
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:
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: