Skip to content

Instantly share code, notes, and snippets.

@davegreen
Created April 19, 2017 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davegreen/10006271bd0856cb0c68fb98b3956cbe to your computer and use it in GitHub Desktop.
Save davegreen/10006271bd0856cb0c68fb98b3956cbe to your computer and use it in GitHub Desktop.
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