Modules/Core/ARIGetSubs.psm1

function Get-ARISubscriptions {
    Param ($TenantID, $Debug)
    if ($Debug.IsPresent)
        {
            $DebugPreference = 'Continue'
            $ErrorActionPreference = 'Continue'
        }
    else
        {
            $ErrorActionPreference = "silentlycontinue"
        }
    Write-Host "Extracting from Tenant $TenantID"
    Write-Debug ((get-date -Format 'yyyy-MM-dd_HH_mm_ss')+' - '+'Extracting Subscription details')
    $Subscriptions = az account list --output json --only-show-errors | ConvertFrom-Json
    $Subscriptions = $Subscriptions | Where-Object { $_.tenantID -eq $TenantID }
    if ($SubscriptionID)
        {
            if($SubscriptionID.count -gt 1)
                {
                    $Subscriptions = $Subscriptions | Where-Object { $_.ID -in $SubscriptionID }
                }
            else
                {
                    $Subscriptions = $Subscriptions | Where-Object { $_.ID -eq $SubscriptionID }
                }
        }
    return $Subscriptions
}