Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXO Module replacement #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions O365-Connect-Office365/Connect-Office365.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ function Connect-Office365 {
Write-Verbose -Message "BEGIN - Import module Lync Online"
Import-Module -Name LyncOnlineConnector -ErrorAction Stop -ErrorVariable ErrorBeginIpmoLyncOnline
}

IF (-not (Get-Module -Name ExchangeOnlineManagement -ListAvailable)) {
Write-Verbose -Message "BEGIN - Import module ExchangeOnlineManagement"
Import-Module -Name ExchangeOnlineManagement -ErrorAction Stop -ErrorVariable ErrorBeginExchangeOnlineManagement
}
}
CATCH {
IF ($ErrorBeginIpmoMSOnline) {
Expand All @@ -46,6 +51,10 @@ function Connect-Office365 {
IF ($ErrorBeginIpmoLyncOnline) {
Write-Warning -Message "BEGIN - Error while importing LyncOnlineConnector module"
}

IF ($ErrorBeginExchangeOnlineManagement) {
Write-Warning -Message "BEGIN - Error while importing ExchangeOnlineManagement module"
}

$PSCmdlet.ThrowTerminatingError($_)
}
Expand All @@ -62,17 +71,13 @@ function Connect-Office365 {
Write-Verbose -Message "PROCESS - Connect to Azure Active Directory"
Connect-MsolService -Credential $Credential

# EXCHANGE ONLINE (Implicit Remoting module)
Write-Verbose -Message "PROCESS - Create session to Exchange online"
$ExchangeURL = "https://ps.outlook.com/powershell/"
$O365PS = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $ExchangeURL -Credential $Credential -Authentication Basic -AllowRedirection -ErrorAction Stop -ErrorVariable ErrorConnectExchange

Write-Verbose -Message "PROCESS - Open session to Exchange online (Prefix: Cloud)"
Import-PSSession -Session $O365PS –Prefix ExchCloud
# EXCHANGE ONLINE (V2)
Write-Verbose -Message "PROCESS - Connect to Exchange online"
Connect-ExchangeOnline -Credential $Credential -ErrorAction Stop -ErrorVariable ErrorConnectExchange

# LYNC ONLINE (LyncOnlineConnector)
Write-Verbose -Message "PROCESS - Create session to Lync online"
$LyncSession = New-CsOnlineSession –Credential $Credential -ErrorAction Stop -ErrorVariable ErrorConnectExchange
$LyncSession = New-CsOnlineSession –Credential $Credential -ErrorAction Stop -ErrorVariable ErrorConnectLync
Import-PSSession -Session $LyncSession -Prefix LyncCloud

# SHAREPOINT ONLINE (Implicit Remoting module)
Expand Down