Skip to content

Instantly share code, notes, and snippets.

@jirrick
Last active May 19, 2017 15:45
Show Gist options
  • Save jirrick/a21101f77346faed06c2a558f5941556 to your computer and use it in GitHub Desktop.
Save jirrick/a21101f77346faed06c2a558f5941556 to your computer and use it in GitHub Desktop.
O365 Service Health PowerShell Demo
#O365 Service Health PowerShell Demo using https://www.powershellgallery.com/packages/O365ServiceCommunications/1.4
#Jiri Hudec - 19.5.2017
#Check O365ServiceCommunications module is installed
if (Get-Module -ListAvailable -Name O365ServiceCommunications ) {
#Ask for credentials
$cred = get-credential -Message "Please enter your Office 365 Administrator credentials"
#Check credentials
if ($cred -ne $null)
{
#Create new session
Write-Host "Creating new session."
$session = New-SCSession -Credential $cred -ErrorAction SilentlyContinue
#Check session
if ($session-ne $null)
{
#Load Incidents and Maintenance events for past 10 days, store to file
Write-Host "Loading Incidents and Maintenance events for past 10 days."
Get-SCEvent -EventTypes Incident,Maintenance -PastDays 10 -SCSession $session | Out-Host
} else {
#Invalid session
Write-Host "Invalid session. Are you using right credentials?"
}
} else {
#No credentials
Write-Host "No credentials provided."
}
} else {
#Instructions for setup
Write-Host "This script requires module 'O365ServiceCommunications' from PowerShell Gallery."
Write-Host "You can install it by executing following command in new PowerShell window:"
Write-Host "Install-Module -Name O365ServiceCommunications -MinimumVersion 1.4 -Scope CurrentUser" -foregroundcolor "yellow"
Write-Host "You will be asked to allow NuGet as installation provider and to trust the PowerShell Gallery repository, in both cases type: 'y' and press Enter."
}
#Clean variables
Remove-Variable cred -ErrorAction SilentlyContinue
Remove-Variable session -ErrorAction SilentlyContinue
Read-Host -Prompt "Press Enter to continue"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment