PSServiceComm is a quick and dirty PowerShell Core Module to talk to the Office 365 Service Communication API, e.g. reading Messages from the Message Center (aka Admin Center).
This PowerShell Module requires an App Registration in your target tenant with Application Permission Scope ServiceHealth.Read for the Office 365 Management APIs. Note down TenantId, ClientId and ClientSecret while creating the App Registration.
Install the PSServiceComm module from: https://www.powershellgallery.com/packages/PSServiceComm
Install-Module -Name PSServiceComm
To authenticate with the Office 365 Service Communication API:
# Use the settings from your app registration
$tenantId = "00000000-0000-0000-0000-000000000000"
$clientId = "00000000-0000-0000-0000-000000000000"
$clientSecret = "ClientSecret" | ConvertTo-SecureString -AsPlainText
Connect-ServiceComm -TenantId $tenantId -ClientId $clientId -ClientSecret $clientSecret
Get all Messages:
$messages = Get-ServiceCommMessages
Get all Messages with a LastUpdatedTime < 5 Days:
$messages = Get-ServiceCommMessages -DaysToSync 5
Get all updated Messages
$messages = Get-ServiceCommMessages
$messages | Where-Object { $_.IsUpdated() }
The API and its documentation don't provide a proper explanation on how to detect updated messages. We consider Messages as updated when the following conditions are met:
Title contains '(Updated)'
LastUpdatedTime > StartTime + 1 Hour