In my recent post about managing change in Office 365 I talked about the role of Message Center notifications in keeping you up to date with changes occurring in the cloud. One of the weaknesses of the Message Center is the lack of email notifications, requiring admins to visit the Office 365 admin portal regularly to keep up with new messages. That’s not very convenient since many admins rarely visit that portal, either due to an infrequent need to perform the tasks that portal makes available (such as license management), or because they’ve done the right thing and automated most of those tasks.
For me personally, email notifications are a must. I prefer sitting at my desk in the morning and scanning through a series of email reports telling me the most important things I need to know, or looking at a single monitoring dashboard to see them, rather than logging into a bunch of different portals to find alerts. The lack of Message Center notifications has bothered me for a long time, and so for the last few months I’ve been using a PowerShell script to check the Message Center every day and email me a digest of new or changed messages.
As I prepared to release the script publicly, my co-author Tony Redmond showed me a Message Center digest email that he’d received for his Office 365 tenant directly from Microsoft. It seems that Message Center email notifications are going to be available, although there’s no mention on the Office 365 road map, and the functionality hasn’t appeared in any of my own tenants yet. As such, I figure I may as well share the script I’ve already written, in case the roll-out to other tenants is slow, and because my script can be scheduled to run as often as you like, whereas the Office 365 email seems to only be a weekly notification.
This script has a dependency on the following functions and modules:
To install the script:
- Add the New-StoredCredential & Get-StoredCredential functions to your PowerShell profile
- Install the O365ServiceCommunications module:
PS> Install-Module -Name O365ServiceCommunications
- Download the latest release from the TechNet Script Gallery.
- Unzip the files to a folder on the workstation or server where you want to run the script.
- Rename Get-MessageCenterDigest.xml.sample to Get-MessageCenterDigest.xml
- Edit Get-MessageCenterDigest.xml with appropriate email settings for your environment. If you exclude the SMTP server, the script will send the report email to the first MX record for the domain of the To address.
- Create a new stored credential by running New-StoredCredential
- Run the script using the usage examples below.
The script will store information about the Message Center messages for a tenant in a file named MessageCenterArchive-tenantdomain.xml, located in the same folder as the script. The first time you run the script, all messages will be reported as “New”. On subsequent runs, the script will use the previous results to determine which messages are new or changed since the last time the script was run. If you delete the XML file or move the script to a different folder, it will report all messages as new again.
If there are no new or changed messages in the Message Center, then no email is sent.
Run the script in a PowerShell console.
.\Get-MessageCenterDigest.ps1 -UseCredential email@example.com
Run the script with verbose output.
.\Get-MessageCenterDigest.ps1 -UseCredential firstname.lastname@example.org -Verbose
Run the script with manual SMTP settings that override the Get-MessageCenterDigest.xml configuration.
.\Get-MessageCenterDigest.ps1 -MailFrom email@example.com -MailTo firstname.lastname@example.org -MailSubject "Your custom subject" -SmtpServer mail.contoso.com
Run the script, suppressing the email report, and generating a HTML file instead.
.\Get-MessageCenterDigest.ps1 -UseCredential email@example.com -NoEmail
You can run the script as a scheduled task as often as you need it to check for new messages. Mine runs daily at 6:45am so that the report is waiting for me when I get to my desk. My scheduled task settings are:
- Run whether use is logged on or not (the user account you use for the scheduled task must be the same as the user you were logged on with when you generated the stored credentials, otherwise the stored credentials can’t be decrypted)
- Action: Start a program
- Program: powershell.exe
- Arguments: -file “D:\Scripts\Office365-Message-Center-Digest\Get-MessageCenterDigest.ps1” -UseCredential firstname.lastname@example.org
If your Office 365 tenant is already receiving the weekly email digests from Message Center, and you’re happy with it, then you probably don’t need this script. Otherwise, please feel free to try this script for yourself, and if you have any questions or feedback please leave a comment below.