Last active
July 18, 2023 12:58
-
-
Save ljtill/a91fb8f9a1dbd9e1479cde5018b04a84 to your computer and use it in GitHub Desktop.
Provides the ability to retrieve the Resource Health of all Resources
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-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