Private/Connect-EgmExchange.ps1
|
function Connect-EgmExchange { <# .SYNOPSIS Ensures the Exchange Online module is available and a connection exists. #> [CmdletBinding()] param() if (-not (Get-Module -ListAvailable -Name ExchangeOnlineManagement)) { throw 'Module ExchangeOnlineManagement is missing. Install with: Install-Module ExchangeOnlineManagement -Scope CurrentUser' } Import-Module ExchangeOnlineManagement -ErrorAction Stop if (-not (Get-ConnectionInformation)) { Connect-ExchangeOnline -ShowBanner:$false } } |