Scroll Top
Evotec Services sp. z o.o., ul. Drozdów 6, Mikołów, 43-190, Poland

Office 365 Health Service using PowerShell

Office 365 Health Service

Two years ago, I wrote a PowerShell module called PSWinDocumentation.O365HealthService. The idea was simple – replicate Health Service data Microsoft offers in Office Portal so you can do with data whatever you want and display it however you like. I've written about it in this blog post. A few weeks back, someone reported that the module stopped working, and  I've confirmed it indeed no longer works! Initially, I thought that maybe some data format changed, as it changed multiple times, or perhaps the date format was wrong again, but no. Microsoft has deprecated Office 365 Service Communications API reference and instead tells us that Service Health is now only available via Microsoft Graph API. Is it only me who didn't get the memo about this?

As Microsoft says on their docs for Office 365 Service Communications API reference:

The legacy version of the Service Communications API that's documented in this article is retired. The service health and communications API in Microsoft Graph is now available and replaces the Service Communications API. For more information about the new Microsoft Graph API, see Overview for accessing service health and communications through Microsoft Graph.

Using PSWindocumentation.O365HealthService

From the module perspective, not much has changed. You still use a single command to get all the data Get-Office365Health.

Import-Module PSWinDocumentation.O365HealthService -Force

$ApplicationID = ''
$ApplicationKey = ''
$TenantDomain = 'evotec.pl' # CustomDomain (onmicrosoft.com won't work), alternatively you can use DirectoryID

$O365 = Get-Office365Health -ApplicationID $ApplicationID -ApplicationKey $ApplicationKey -TenantDomain $TenantDomain
$O365

The output is a hashtable, with all the data sorted into eight categories. Since GraphAPI has a bit different dataset, I was unable to preserve all available types from before, and of course, properties had to change. But the changes aren't massive, so if you're using this for something – it's pretty easy to fix it.

Graph API permissions required

The module now requires a bit different permissions. You can remove old ones, as those don't do anything anymore. It would be nice if Microsoft marked them as obsolete rather than just let them stay there. Maybe an email saying – we changed something, and since we're using it – please update – would be great!

New requirements for Health Service

Office 365 Health Dashboard

Finally, by using PSWindocumentation.O365HealthService and combining it with PSWriteHTML, you get a friendly little dashboard that you can incorporate into your other projects.

Import-Module PSWinDocumentation.O365HealthService -Force
Import-Module PSWriteHTML -Force

$ApplicationID = ''
$ApplicationKey = ''
$TenantDomain = 'evotec.pl' # CustomDomain (onmicrosoft.com won't work), alternatively you can use DirectoryID

$O365 = Get-Office365Health -ApplicationID $ApplicationID -ApplicationKey $ApplicationKey -TenantDomain $TenantDomain -Verbose 

Dashboard -FilePath $PSScriptRoot\Health.html {
    TabOption -BorderRadius 0px -BackgroundColorActive DimGrey
    SectionOption -BorderRadius 0px -HeaderBackGroundColor DimGrey
    TableOption -DataStore JavaScript -ArrayJoinString "; " -ArrayJoin -BoolAsString
    Tab -Name 'Services' {
        Section -Name 'Service List' {
            Table -DataTable $O365.Services -Filtering
        }
    }
    Tab -Name 'Current Status' {
        Section -Invisible {
            Section -Name 'Current Status' {
                Table -DataTable $O365.CurrentStatus {
                    TableCondition -Name 'ServiceStatus' -Value 'serviceOperational' -BackgroundColor MintGreen -FailBackgroundColor Salmon
                } -Filtering
            }
            Section -Name 'Current Status Extended' {
                Table -DataTable $O365.CurrentStatusExtended {
                    TableCondition -Name 'ServiceStatus' -Value 'serviceOperational' -BackgroundColor MintGreen -FailBackgroundColor Salmon
                } -Filtering
            }
        }
    }
    Tab -Name 'Message Center Information' {
        #Section -Invisible {
        Section -Name 'Message Center' {
            Table -DataTable $O365.MessageCenterInformation -Filtering
        }
        Section -Name 'Message Center Extended' {
            Table -DataTable $O365.MessageCenterInformationExtended -InvokeHTMLTags -Filtering
        }
        #}
    }
    Tab -Name 'Incidents' {
        Section -Invisible {
            Section -Name 'Incidents' {
                Table -DataTable $O365.Incidents -Filtering {
                    TableCondition -Name 'IsResolved' -Value $true -BackgroundColor MintGreen -FailBackgroundColor Salmon -ComparisonType bool
                }
            }
            Section -Name 'Incidents Extended' {
                Table -DataTable $O365.IncidentsExtended -Filtering {
                    TableCondition -Name 'IsResolved' -Value $true -BackgroundColor MintGreen -FailBackgroundColor Salmon -ComparisonType bool
                }
            }
        }
        Section -Name 'Incidents Messages' {
            Table -DataTable $O365.IncidentsUpdates -InvokeHTMLTags -Filtering
        }
    }
} -Online -ShowHTML

PSWinDocumentation.O365HealthService - How do you install it?

Using the install module, you can install PSWindocumentation.O365HealthService straight from PowerShellGallery. The module is signed and minimized.

Install-Module -Name PSWinDocumentation.O365HealthService -Force

That's it. Notice how I'm using Force. I use Force because it redownloads PSWinDocumentation.O365Health and makes sure it's up to date.

Related Posts