Skip to content

Instantly share code, notes, and snippets.

Created Oct 17, 2017
Embed
What would you like to do?
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