Skip to content

Instantly share code, notes, and snippets.

@davegreen
Created April 19, 2017 21:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Function TestMsolConnection {
<#
.Synopsis
A function that tests the Microsoft Online connection.
.Description
A function that tests the Microsoft Online connection.
.Example
TestMsolConnection
Tests to see if the Microsoft Online connection is available.
.Notes
Author: David Green
#>
[CmdletBinding()]
[OutputType(
[bool]
)]
Param()
try {
Get-MsolCompanyInformation -ErrorAction Stop | Out-Null
Write-Verbose 'Microsoft Online connection test success.'
Write-Output $true
}
catch [Microsoft.Online.Administration.Automation.MicrosoftOnlineException] {
Write-Verbose 'Microsoft Online connection test failure.'
Write-Output $false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment