Last active
September 12, 2017 12:11
-
-
Save ehrnst/ed7e6c345c47048dbda676d1bdec8a04 to your computer and use it in GitHub Desktop.
Get Azure resource health by resource group
This file contains 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
availabilityState : Unavailable | |
summary : Your virtual machine is unavailable | |
detailedStatus : We're working to automatically recover your virtual machine and to determine the source of the problem. No additional action is required from you at this time. | |
reasonType : Unplanned | |
occuredTime : 2017-07-30T01:13:56Z | |
reasonChronicity : Persistent | |
reportedTime : 2017-09-12T11:27:42.3921293Z | |
resolutionETA : 2017-07-30T01:38:56Z |
This file contains 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
#get the health of the whole resource group | |
# Add each health status to a hashtable before output a complete table with all resource groups and their resource health | |
$resourceGroupHealth = @{} | |
foreach ($ResourceGroup in $ResourceGroups) { | |
#Set resource group name and use it in our url | |
$health = Invoke-RestMethod -Uri "https://management.azure.com/subscriptions/$subscriptionID/resourceGroups/$ResourceGroup/Providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2015-01-01" -Method GET -Headers $authHeader | |
$currentHealth = @{} | |
$currentHealth = @{ | |
[string]"$ResourceGroup" = [object]$health | |
} | |
$resourceGroupHealth += $currentHealth | |
} | |
$resourceGroupHealth | |
#Explore the results | |
$resourceGroupHealth.item('ResourceGroup').Value.Properties |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment