Function Connect-EXOLegacy {

    Creates a connection to Exchange online using Legacy Auth (BASIC)
    Connecto to Exchange Online in the Legacy Manner using Basic Authentication
    .PARAMETER Credential
    Credential Object used to connect to EXO.
    If not provided user will be prompted for it.
    None. Creates a PS session to EXO and imports it into the global scope
    Will prompt for credentials and import Exchange PS Session into the global scope
    $Cred = Get-Credential
    Connect-EXOLegacy -Credential $Cred
    Will used the $cred credential to connect to exchange Online


    # If we don't have a credential then prompt for it
    $i = 0
    while (($Null -eq $Credential) -and ($i -lt 5)) {
        $Credential = Get-Credential -Message "Please provide your Exchange Online Credentials"
    # If we still don't have a credentail object then abort
    if ($null -eq $Credential) {
        Write-Error -Message "Failed to get credentials" -ErrorAction Stop
    # Check for a previous sesison and remove it
    Get-PSSession -name Legacy_EXO* | Remove-PSSession -Confirm:$false

    # Create and import the session
    $session = New-PSSession -Name Legacy_EXO -ConfigurationName Microsoft.Exchange -ConnectionUri "" -Credential $Credential -Authentication Basic -AllowRedirection
    Import-Module (Import-PSSession $Session -AllowClobber) -Global -WarningAction 'SilentlyContinue'