Functions/Get-GSuiteUserAlias.ps1

<#
.SYNOPSIS
    This function gets alias information of a GSuite user.
    This function returns either String when there is one alias, or Object[] when there is more than one alias.
    This returns the same result as (Get-GSuiteUser -primaryEmailAddress $primaryEmailAddress).alias
#>

function Get-GSuiteUserAlias {
    [CmdletBinding(PositionalBinding=$false)]
    [OutputType([Object[]], [String])]
    param (
        # The primary email address of the user.
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [String]$primaryEmailAddress
    )

    # Validate that the 'connection' has been established and the user access token exists
    Assert-GSuiteConnection -Scope "User"

    # Prepare REST call parameters
    $invokeRestMethodParams = @{
        Uri     = "https://www.googleapis.com/admin/directory/v1/users/$($primaryEmailAddress)/aliases"
        Method  = "GET"
        Headers = @{
            Accept        = "application/json"
            Authorization = "Bearer $($Global:GSuiteAccessTokensHashTable.User)"
        }
    }

    # Invoke the REST call
    $response = Invoke-RestMethod @invokeRestMethodParams

    # return the aliases of the user
    return $response.aliases.alias
}