source/public/Get-MS365HealthOverview.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
Function Get-MS365HealthOverview { [cmdletbinding(DefaultParameterSetName = 'All')] param ( [Parameter(Mandatory)] [string] $Token, # List of services to retrieve [Parameter()] [string[]]$Workload ) $headers = @{"Authorization" = "Bearer $($Token)" } $uri = "https://graph.microsoft.com/beta/admin/serviceAnnouncement/healthOverviews" if ($Workload) { $uri = "$uri`?`$filter=service eq '$($Workload[0])'" for ($i = 1; $i -lt $workload.Count; $i++) { $uri = "$uri or service eq '$($Workload[$i])'" } } SayInfo "Query = $uri" try { $response = @((Invoke-RestMethod -Uri $uri -Method GET -Headers $headers -ErrorAction STOP).value) } catch { SayError "$($_.Exception.Message)" return $null } return $($response | Sort-Object service) } |