I am trying to get a list of Azure vm statuses (Allocated,Deallocated). I am able to get it one at a time for a single vm. But when i have a list of VM's or when using wildcard's it fails to get the vm status. Any tips
$ResGrp= "resvmtest"
$action="start"
$vmList = Get-AzVM -ResourceGroupName $ResGrp -Name * -Status
foreach($vm in ($vmList | Select-Object @batch)){
Write-Host $vm.Statuses[1].DisplayStatus
}
I see that you were trying to display the VMs in batches. Unless you have VMs in the thousands, that's not necessary. I also no longer see the Statuses
property in Get-AzVM cmdlet. Just try this:
$vmList = Get-AzVM -ResourceGroupName $ResGrp -Status
$vmList | Select-Object Name, PowerState, ProvisioningState # or any other properties you want to display
Either that or I'm not understanding your question.