Efficient Cloud Services Health Checks with PowerShell for M365

Maintaining the health of your Microsoft 365 environment is crucial for ensuring seamless operations and user satisfaction. This PowerShell script automates the process of checking the health status of core M365 services, allowing administrators to identify any issues that may affect users.
This script will:
1. Connect to Microsoft 365 using Microsoft Graph.
2. Retrieve and display the health status of key M365 services.
3. Output any issues detected alongside their impact levels.
By using this script, IT administrators can proactively manage service health, ensuring that any potential disruptions are addressed in a timely manner.

# Install Microsoft.Graph module if not already installed
if (-Not (Get-Module -ListAvailable -Name Microsoft.Graph)) {
    Install-Module -Name Microsoft.Graph -Scope CurrentUser -AllowClobber
}
# Connect to Microsoft Graph
Connect-MgGraph -Scopes 'ServiceHealth.Read.All'
# Get the service health status
$serviceHealth = Get-MgServiceHealth
Write-Host "=== Microsoft 365 Service Health Status ==="
foreach ($service in $serviceHealth) {
    Write-Host "Service: $($service.ServiceArea) - Status: $($service.Status) - Message: $($service.Message)"
}
# Disconnect from Microsoft Graph
Disconnect-MgGraph
Write-Host "Health check completed."