Last active
July 18, 2023 12:59
-
-
Save ljtill/0fcea1ce413ee90a238f19d0cc4ce91a to your computer and use it in GitHub Desktop.
Provides the ability to retrieve all historical Resource Health
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-AzureRmResourceHealthHistory { | |
| <# | |
| .SYNOPSIS | |
| Get-AzureRmResourceHealthHistory will retrieve the Resource Health History of a Resource. | |
| .DESCRIPTION | |
| Provides the ability to retrieve all historical Resource Health of a specific Resource Id. | |
| .EXAMPLE | |
| Get-AzureRmResourceHealthHistory -ResourceId $resourceId -AccessToken $accessToken. | |
| .LINK | |
| https://gist.github.com/ljtill | |
| #> | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter()] | |
| [string]$ResourceId, | |
| [Parameter()] | |
| [string]$AccessToken | |
| ) | |
| begin { | |
| $apiVersion = "2017-07-01" | |
| $request = @{ | |
| Method = "GET" | |
| Uri = ("https://management.azure.com/" + $resourceId + "/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=" + $apiVersion) | |
| Headers = @{ | |
| "Authorization" = ("Bearer " + $accessToken) | |
| "Accept" = "application/json" | |
| } | |
| Body = $null | |
| } | |
| } | |
| process { | |
| $response = Invoke-RestMethod @request | |
| } | |
| end { | |
| return $response.value | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment