Getting Virtual machine scalesets instance report

43 views Asked by At

I am trying to pull report of Virtual machine scale sets using resource graph but doesn't seem getting instance count on each VMSS but when i tried to pull with powershell module able to pull the report but both counts are not matching on No of VMSS in the tenant.

Resource graph used to pull VMSS count

$AllSubIDs = Get-AzSubscription -TenantId "id"
    Foreach ($Sub in $AllSubIDs) {
    Set-AzContext -SubscriptionId $sub.id -WarningAction Ignore
   $VMSSCount = Get-AzResource | Where-Object {$_.ResourceType -eq "Microsoft.Compute/virtualMachineScaleSets"}
    $VMSSCount.count
    }

and to fetch instance count with powershell used by looping through each subscription i got count of 3000+ where as resource graph showed only 1800+

Get-AzVmss -VMScaleSetName "VMSS001"

Can any one please share script to get exact count of VMSS and instances running in it.

Thanks Ted

1

There are 1 answers

0
kalyani On

Solved, found in Resource Graph Explorer:

Resources
| where type=~ 'microsoft.compute/virtualmachinescalesets'
| project subscriptionId, name, location, resourceGroup, Capacity = toint(sku.capacity), Tier = sku.name
| order by Capacity desc