Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save ljtill/a91fb8f9a1dbd9e1479cde5018b04a84 to your computer and use it in GitHub Desktop.
Provides the ability to retrieve the Resource Health of all Resources
function Get-AzureRmResourceHealth {
<#
.SYNOPSIS
Get-AzureRmResourceHealth will retrieve the Resource Health of all Resources within a Subscription.
.DESCRIPTION
Provides the ability to retrieve the current status of all Resources within a specific Subscription Id.
.EXAMPLE
Get-AzureRmResourceHealth -SubscriptionId $subscriptionId -AccessToken $accessToken.
.LINK
https://gist.github.com/ljtill
#>
[CmdletBinding()]
param (
[Parameter()]
[string]$SubscriptionId,
[Parameter()]
[string]$AccessToken
)
begin {
$apiVersion = "2017-07-01"
$request = @{
Method = "GET"
Uri = ("https://management.azure.com/subscriptions/" + $subscriptionId + "/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