Functions/Get-Office365ServiceHealth.ps1
# Credits to HARM VEENSTRA - https://powershellisfun.com/2022/05/23/get-365-service-health-status-using-powershell/ function Get-Office365ServiceHealth { [CmdletBinding()] param ( ) if (!(Get-MgContext)) { return "Not connected to MS Graph" } #Display non-resolved Issues sorted on StartDateTime, display error when unable to retrieve try { $issues = Get-MgServiceAnnouncementIssue | Where-Object IsResolved -NE True | Select-Object StartDateTime, Id, ImpactDescription, Feature, Classification, Status | Sort-Object StartDateTime } catch { return ("Error retrieving Announcements, try again later...") } #Display the issues if found, display no issues found it not if ($issues.count -gt 0) { return $issues } else { return ("No 365 Service Health Issues found!") } } |