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!