Skip to content

Instantly share code, notes, and snippets.

Created October 17, 2017 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/59d6826c026b9c1750309817db594cf3 to your computer and use it in GitHub Desktop.
Save anonymous/59d6826c026b9c1750309817db594cf3 to your computer and use it in GitHub Desktop.
Office365
# gather events from the Service Communications API
$MySession = New-SCSession -Credential $Credential
$Events = Get-SCEvent -EventTypes Incident -PastDays 1 -SCSession $MySession |
Select-Object Id, Status, StartTime,
@{n='ServiceName'; e={$_.AffectedServiceHealthStatus.servicename}},
@{n='Message';e={$_.messages[0].messagetext}}
$a = "<style>BODY{background-color:peachpuff;}</style>"
$event | Out-GridView # ConvertTo-Html -Head $a | Out-File N:\health.html
if ($Events)
{
$Tables = foreach ($Event in $Events)
{
@"
<table>
<tr>
<th>Id</th>
<th>ServiceName</th>
<th>Status</th>
<th>StartTime</th>
</tr>
<tr>
<td>$($Event.Id)</td>
<td>$($Event.ServiceName)</td>
<td>$($Event.Status)</td>
<td>$($Event.StartTime)</td>
</tr>
</table>
<table>
<tr>
<td>$($Event.Message)</td>
</tr>
</table>
"@
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment