src/Connect-cciAzAccount.ps1
function Connect-cciAzAccount { [CmdletBinding()] param ( $SubscriptionID, $TenantId ) begin { Write-Verbose "Started running $($MyInvocation.MyCommand)" $cciConnectionParams = Get-cciConnectionParams if (!($subscriptionName)) { $subscriptionName = $cciConnectionParams.AzAccount_subscriptionName } if (!($SubscriptionID)) { $SubscriptionID = $cciConnectionParams.SubscriptionID } if (!($TenantId)) { $TenantId = $cciConnectionParams.TenantId } $CciAZContext = @{ 'SubscriptionID' = $SubscriptionID 'TenantId' = $TenantId } } process { while (!(Get-AzContext)) { Write-Verbose "Logging in to $($subscriptionName)..." Connect-AzAccount @CciAZContext -Verbose } } end { Write-Verbose "Finished running $($MyInvocation.MyCommand)" } } |