PowerShell 3.0: How to get Office 365 Service Health alerts in email? (from RSS feed)


Microsoft has awesome Office 365 Admin app on iPhone, Android and Windows phones. But I came across some old school IT guys wants to see Office 365 cloud service alerts in emails. So I wrote a PowerShell script with Invoke-RestMethod cmdlet. Feel free to reuse this script to your needs.

Before you start using this script, you need two things. Office 365 Service Health RSS URI for your organization and a SMTP server to send emails out.

To get the Office 365 Service Health RSS URI:

1. You need to log in to Office 365 with administrator account.
2. Expand and Go to Service Health/Service Health Page.
3. click on RSS icon on top right (see picture below).

 

O365ServiceHealth O365ServiceHealth1

 

4. Copy the whole RSS address URI from the Address bar, and keep it in a notepad

 

O365ServiceHealthURI

Now here is my script. Copy and paste the RSS URI into the script to replace Value for the variable $URI. Change the From/To/SMTP server address in the script. Save the script and schedule it to run every day (or hour, etc.,).

Your download this script from here: Office365Monitor.ps1

<#
Function: Send-Email
Parameters: FromAddress,ToAddress, Subject, Body,
Attachment (array of files)
Purpose: Send email to specified email address
with given subject, body and attachments

Written by: Anand, the awesome, Venkatachalapathy
#>
Function Send-Email()
{
Param (
$fromaddress = “donotreply@company.com”,
$toaddress = “AwesomeAnand@company.com”,

$Subject = “Action Required”,
$body,
$HTMLBody = $false,
$attachment = @(),
$smtpserver = “screeming-smtp.company.com”
)

$message = new-object System.Net.Mail.MailMessage
$message.From = $fromaddress

if ($toaddress.Length -gt 0)
{ $message.To.Add($toaddress) }

$message.IsBodyHtml = $HTMLBody
$message.Subject = $Subject

$attachment.foreach( {
$attach = new-object Net.Mail.Attachment($_)
$message.Attachments.Add($attach)
} )

$message.body = $body
$smtp = new-object Net.Mail.SmtpClient($smtpserver)
$smtp.Send($message)
}
# End of Send-Email Funcation

<#
* * * * The Script Starts here * * * *
Script: Office365Monitor.ps1
Purpose: Get Office 365 Service health alerts in
email (from RSS feed)

Usage: Find out your RSS alert URI by
1. logging in to your Office 365 portal
as administrator,
2. go to “Service Health”section,
3. click on RSS icon on top right,
4. Copy and paste the address (URI) to
this script below for value for $URL variable

Don’t forget to change the from/to/smtp server
addresses in this script.

Written by: Anand, the Awesome, Venkatachalapathy
Written Date: Jan 2015
#>

#URI from Office 365 service health RSS section
$URI = “http://rss.servicehealth.microsoftonline.com/feed/en-US/..”

#Get the REST representation resource from Office 365 RSS URI
$O365Status = Invoke-RestMethod -Uri $URI

$Alerts = “”

#Collect all degraded service information
foreach($Status in $O365Status)
{

if ($Status.Description -like ‘*degradation*’)
{

$Alerts += $Status.pubDate + “`n” + $Status.title + “`n” + `
$Status.description + “`n” + $Status.link + “`n`n”

}
}

#send email
if ( $ExchAlerts.Length -gt 10)
{
Send-Email -fromaddress “Office365ServiceMonitor@company.com” `
-toaddress “awesomeanand@gmail.com” `
-Subject “Office 365 Service is degraded” `
-body $Alerts -HTMLBody:$true `
-smtpserver “ScreemingSMTP.company.com”
}

<#
* * * * The Script Ends Here * * * *
#>

8 thoughts on “PowerShell 3.0: How to get Office 365 Service Health alerts in email? (from RSS feed)

    1. Hello PinPin,
      I did verify the link and it is working link. After you click the link, wait for 5 secs in adf.ly site and then click on Skip the AD on top right.

      Regards,
      AnandtheArchitect

  1. Hello Anand,

    As per Microsoft’s Recent Update. RSS feed is not longer available for Office 365 Service Health Alert. (Check Link)
    http://ngenioussolutions.com/blog/microsoft-is-removing-the-rss-feature-from-the-office-365-service-health-dashboard/

    So we can no more receive the service health incidents via email in Outlook. The two solution remain is to either manually visit the Service Health Page from Office 365 Admin Portal or download the smartphone app for iPhone and Android which is Office 365 Admin App and then check the Health Status from there.

    The RSS feed button also does not show up in the Office 365 portal – Service Health Section now.

    Could you come up with another working solution for this so that we can retrieve the service health updates via email?

    1. Hi Anand,
      Thanks for the command. The command didn’t exactly run. May be I did something wrong but I tweaked the script you gave with some of my own script file and now it triggers email alerts when there is a service degradation.
      Thank you so much for the script file. Appreciate that (Y)
      Regards,
      Vinayak Chakrabarti

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s