Skip to content

Instantly share code, notes, and snippets.

@fitzgeraldsteele
Created March 16, 2021 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitzgeraldsteele/a937cb74e254a04e1f1960c00a30de40 to your computer and use it in GitHub Desktop.
Save fitzgeraldsteele/a937cb74e254a04e1f1960c00a30de40 to your computer and use it in GitHub Desktop.
Find all unhealth instances in a VMSS
$allInstances = Get-AzVmssVM -InstanceView -ResourceGroupName $rg -VMScaleSetName $vmssName
$unhealthyInstances = $allInstances | where {$_.InstanceView.VmHealth.Status.Code -eq "HealthState/unhealthy"}
Write-Output "Total instances: $($allInstances.Count)"
Write-Output "Unhealthy instances: $($unhealthyInstances.Count)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment