Functions/Get-AllAzureADUsers.ps1

<#
.SYNOPSIS
    This function retrieves all the users present on Azure AD.
.DESCRIPTION
    This function retrieves all the users present on Azure AD.
    If the environment is set as not testing (production), it retrieves the users directly from
    Azure AD.
    Otherwise, it retrieves the list of users in the test environment instead.
#>

function Get-AllAzureADUsers {
    # The environment is set to testing
    if ((Get-BT_RunbookEnvironment).IsTestEnvironment) {
        return Get-Office365TestEnvironmentAvailableUsers -TestID $Global:Office365TestRunID -ActiveDirectory
    }

    # The environment is not set to testing
    else {
        return Get-AzureADUser -All $true
    }
}