Skip to content

Instantly share code, notes, and snippets.

@ljtill
Last active July 18, 2023 12:59
Show Gist options
  • Select an option

  • Save ljtill/0fcea1ce413ee90a238f19d0cc4ce91a to your computer and use it in GitHub Desktop.

Select an option

Save ljtill/0fcea1ce413ee90a238f19d0cc4ce91a to your computer and use it in GitHub Desktop.
Provides the ability to retrieve all historical Resource Health
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