helpers/Connect-O365Skype.ps1
function Connect-O365Skype { PARAM ( [System.Management.Automation.PSCredential] $Credential ) try { Import-Module -Name SkypeOnlineConnector -DisableNameChecking -Force -ErrorAction Stop } catch { Write-Error -Message "The module 'SkypeOnlineConnector' was not found. A connection to Skype for Business will not be established" } $Option = New-PSSessionOption -IdleTimeout -1 $SkypeSession = New-CsOnlineSession -Credential $Credential -SessionOption $Option $ModuleName = 'SkypeForBusiness' $ModulePath = Join-Path $AppdataPath $ModuleName $null = Export-PSSession -Session $SkypeSession -OutputModule $ModulePath -AllowClobber -Force Import-Module $ModulePath -Global -DisableNameChecking } |