In the world of basic authentication, I used to connect to MSOL, Compliance and Exchange in a series that went like this:
function ConnectToCloud()
{
$CloudCredentials = import-clixml C:\tools\CloudCreds.xml
Write-Host "Connecting To Compliance Online..." -foregroundcolor white -BackgroundColor Green
$Session1 = New-PSSession -Name "Session1" -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid `
-Credential $CloudCredentials -Authentication Basic -AllowRedirection -WarningAction SilentlyContinue
Import-PSSession $Session1 -Prefix CP -DisableNameChecking -AllowClobber | Out-Null
Write-Host "Connecting To Exchange Online..." -foregroundcolor white -BackgroundColor Green
$Session2 = New-PSSession -Name "Session2" -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell `
-Credential $CloudCredentials -AllowRedirection -WarningAction SilentlyContinue
#Import-PSSession $Session2 -Prefix Cloud -DisableNameChecking -AllowClobber | Out-Null
Connect-MsolService -Credential $CloudCredentials
Write-Host "Starting the Checks..." -foregroundcolor white -BackgroundColor Green
}
In the world of Modern Auth, we're supposed to connect to Compliance with:
Connect-IPPSSession -Credential $CloudCredentials
and connect to Exchange with:
Connect-ExchangeOnline -Credential $CloudCredentials
the connect to MSOL hasn't changed.
The problem is that when I run Connect-ExchangeOnline, it DISCONNECTS me from Compliance and vice-versa How can I, in a script connect to all THREE services simultaneously, using modern auth?
Thanks!
It seems I was using the "preview" module of the Online connection.
If I use the one that you get via the Exchange Online reference, then the following commands work to connect to BOTH compliance and Exchange Online
Note - I can't use
New-EXOPSSession
because it won't let me give it a Credential parameter... Interactive logins don't work so well in a script :(I am glad to know the issue has been resolved, please mark the helpful replies as answers, this will make answer searching in the forum easier and be beneficial to other community members as well.