Functions/Get-AllExchangeOnlineUsers.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<#
.SYNOPSIS
    This function retrieves all the users present on Exchange Online.
.DESCRIPTION
    This function retrieves all the users present on Exchange Online.
    If the environment is set as not testing (production), it retrieves the users directly from
    Exchange Online.
    Otherwise, it retrieves the list of users in the test environment instead.
#>

function Get-AllExchangeOnlineUsers {
    # The environment is set to testing
    if ((Get-BT_RunbookEnvironment).IsTestEnvironment) {
        return Get-Office365TestEnvironmentAvailableUsers -Domain (Get-EmailAddressDomain $Global:ExchangeOnlineUsername) -ExchangeOnline
    }

    # The environment is not set to testing
    else {
        return Get-User -ResultSize unlimited
    }
}