Unable to Retrieve Exchange Online Properties

I'll be opening a ticket as well, but wanted to see if there was quick answer someone had.   We have a newly installed 8.1.1 environment, configured against the same Azure AD tenant as our 7.5.3 non-prod environment.  Wa are testing 8.1.1 prior to cut over.  The 7.5.3 environment works correctly, but 8.1.1 complains it can't connect to Exchange Online.  I can, on the 8.1.1 environment, log on under the ARS service account (RunAs on PowerShell), which has the ActiveRoles self-signed certificate, and connect to ExchangeOnline with it, and successfully retrieve the mailbox attributes.



ARS 8.1.1 has the same consented permissions as 7.5.3

Same Admin Servers, running under the service account context

Parents
  • may be silly, but what version of exchangeOnlineManagement is installed?  be sure it is 3.1.0

  • We discovered the issue.  Don't issue disconnect-exchangeonline in your script, as it seems to disconnect all exchange sessions inside ARS

    Our Library script for EXO now looks as follows, checking for an existing active session.

    function onInit($Context) {
        $Context.UseLibraryScript("Library Scripts/UPenn/Include_Debug")
        $Context.UseLibraryScript("Library Scripts/BestPractices-PowerShell")
        
    }
    
    
    function Connect-Exchange {
    if((Get-ConnectionInformation).TokenStatus -ne 'Active')
    {
    
          
            $IdleTimeout = $( New-PSSessionOption -IdleTimeout $(New-TimeSpan -Minutes 600000).TotalMinutes)
    
    
            $cert=gci -path cert:/CurrentUser/My `
                      | Where-Object {$_.Subject -like "cn=ActiveRoles" } `
                      | Select thumbprint, 
                               @{N='StartDate';   E={$_.NotBefore}},
                               @{N='EndDate';     E={$_.NotAfter }},
                               @{N='DaysRemaining';E={($_.NotAfter - (Get-Date)).Days}} `
                               | Sort-Object -Property DaysRemaining -Descending | select -first 1
    
    
           
             Connect-ExchangeOnline -Organization $tenant `
                                    -AppId $clientID `
                                    -CertificateThumbprint $cert.Thumbprint `
                                    -CommandName get-mailbox,
                                                 Add-MailboxPermission,
                                                 Remove-MailboxPermission,
                                                 Get-MailboxFolderPermission,
                                                 Get-MailboxFolderStatistics,
                                                 Add-RecipientPermission,
                                                 Remove-RecipientPermission,
                                                 Get-RecipientPermission,
                                                 Get-MailboxPermission,
                                                 set-mailbox,
                                                 Get-MailboxStatistics,
                                                 Add-MailboxFolderPermission,
                                                 Remove-MailboxFolderPermission,
                                                 Set-MailboxFolderPermission `
                                    -PSSessionOption $IdleTimeout `
                                    -ShowProgress:$false `
                                    -ShowBanner:$false `
                                    -UseMultithreading:$true `
                                    -FormatTypeName *  
                                    
                                   
      }
    }
    
    function Disconnect-Exchange {
    #Disconnect-ExchangeOnline -confirm:$false
    
    }

  • question: when firing a new workflow that calls the connection function, does it create a new connection to ExOL?  If so, doesn't that also create a new "tmpEXO_" folder in you %temp% folder?  Properly disconnecting from ExOL will remove that "tmpEXO_" folder. I wasn't disconnecting from ExOL for my scripts before and filled up my temp drive.

  • We were disconnecting after calling an exchange cmdlet under 7.5.3 with the v1/v2 commands. That didn't seem to make a difference with the temp dir.  

Reply Children
No Data