Hi @Abhishek P,
Below script works which gives the Power State of VMSS:
$rsgrpname = "rithwik"
$vmssperu = "test67"
$vmssInstances = Get-AzVmssVM -ResourceGroupName $rsgrpname -VMScaleSetName $vmssperu -InstanceView
$vmssInstances | ForEach-Object {
$instId = $_.InstanceId
$vmName = $_.Name
$instanceDetails = Get-AzVmssVM -ResourceGroupName $rsgrpname -VMScaleSetName $vmssperu -InstanceId $instId -InstanceView
$rith_power = ($instanceDetails.Statuses | Where-Object { $_.Code -match "PowerState" })?.DisplayStatus
[PSCustomObject]@{
VMName = $vmName
InstanceID = $instId
ProvisioningState = $_.ProvisioningState
PowerState = $rith_power
}
}
I have VMSS Powers state as below:
Output:
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.