I'm working on a script that involves jumping between two different user accounts in two different Azure tenants. With the Az
powershell module, I can set different auth contexts using:
Connect-AzAccount -ContextName "FirstContext" # interactive auth prompt 1
Connect-AzAccount -ContextName "SecondContext" # interactive auth prompt 2
then jump between them without any additional interactive prompts like this:
Select-AzContext -Name "FirstContext"
# do stuff within the first context
Select-AzContext -Name "SecondContext"
# do stuff within the second context
I need to do something similar (jumping back and forth between auth contexts in the same script) using cmdlets in the AzureAD
powershell module now... Does anyone know this may be able to be achieved? Both auth contexts require interactive MFA, which Get-Credential
doesn't seem to support.
Thanks!