Microsoft365ServiceStatus.psm1
#Region '.\_PrefixCode.ps1' 0 # Code in here will be prepended to top of the psm1-file. #EndRegion '.\_PrefixCode.ps1' 1 #Region '.\Private\Get-APIUrl.ps1' 0 function Get-APIUrl { [CmdletBinding()] param ( ) process { return @{ URL = $script:apiURL } } } #EndRegion '.\Private\Get-APIUrl.ps1' 12 #Region '.\Private\Get-AuthHeader.ps1' 0 function Get-AuthHeader { [CmdletBinding()] param ( ) process { if ($null -ne $script:msalToken) { return @{ "Content-Type" = "application/json" "Authorization" = $script:msalToken.CreateAuthorizationHeader() "ExpiresOn" = $script:msalToken.ExpiresOn.LocalDateTime } } else { throw "You need to obtain and store an access token with `"Get-MsalToken`" & `"Set-MsalToken`" before you can use this module." } } } #EndRegion '.\Private\Get-AuthHeader.ps1' 19 #Region '.\Public\Get-M365ServiceHistoricalStatus.ps1' 0 function Get-M365ServiceHistoricalStatus { [CmdletBinding()] param ( ) process { try { $uri = "$script:apiURL/HistoricalStatus" $historicalStatus = Invoke-RestMethod -Method Get -Uri $uri -Headers $(Get-AuthHeader) -UseBasicParsing -EA Stop return $historicalStatus.value } catch { Write-Error $_ } } } #EndRegion '.\Public\Get-M365ServiceHistoricalStatus.ps1' 17 #Region '.\Public\Get-M365ServiceMessages.ps1' 0 function Get-M365ServiceMessages { [CmdletBinding()] param ( ) process { try { $uri = "$script:apiURL/Messages" $serviceMessages = Invoke-RestMethod -Method Get -Uri $uri -Headers $(Get-AuthHeader) -UseBasicParsing -EA Stop return $serviceMessages.value } catch { Write-Error $_ } } } #EndRegion '.\Public\Get-M365ServiceMessages.ps1' 17 #Region '.\Public\Get-M365ServiceStatus.ps1' 0 function Get-M365ServiceStatus { [CmdletBinding()] param ( # Only show brief status [Parameter()] [switch] $Brief ) process { try { $uri = "$script:apiURL/CurrentStatus" $serviceStatus = Invoke-RestMethod -Method Get -Uri $uri -Headers $(Get-AuthHeader) -UseBasicParsing -EA Stop if ($Brief.isPresent) { return $serviceStatus.value | Select-Object -Property WorkloadDisplayName, StatusDisplayName, IncidentIds, StatusTime } else { return $serviceStatus.value } } catch { Write-Error $_ } } } #EndRegion '.\Public\Get-M365ServiceStatus.ps1' 26 #Region '.\Public\Set-MsalToken.ps1' 0 function Set-MsalToken { [CmdletBinding()] param ( # Store MsalToken [Parameter(Mandatory)] [object] $MsalToken ) process { $script:msalToken = $MsalToken $script:apiURL = "https://manage.office.com/api/v1.0/$($script:msalToken.TenantId)/ServiceComms" } } #EndRegion '.\Public\Set-MsalToken.ps1' 14 |