Forum Discussion
VM Agent Status and Version Reporting
- Dec 26, 2019
nathan_mitten_rpa, when you query for an individual VM with the "Status" switch, you get the VM Agent details, as follows:
$vm = Get-AzVm -Name "vm name" -ResourceGroupName "RG name" -Status
$vm.VMAgent.VmAgentVersion
However, the VM must be running to get all the details.
nathan_mitten_rpa, when you query for an individual VM with the "Status" switch, you get the VM Agent details, as follows:
$vm = Get-AzVm -Name "vm name" -ResourceGroupName "RG name" -Status
$vm.VMAgent.VmAgentVersion
However, the VM must be running to get all the details.
- david1718Feb 23, 2022Copper Contributor
Hi hspinto
IS there a way to do this based at the RG level so I can get the agent version from all my vms that are on that RG
- hspintoFeb 23, 2022
Microsoft
I believe there's a more efficient way of doing it, but this should work:
$vmStatuses = @(); Get-AzVM -ResourceGroupName myResourceGroupName | ForEach-Object { $vmStatus = Get-AzVM -Status -ResourceGroupName $_.ResourceGroupName -Name $_.Name; $vmStatuses += $vmStatus }
The $vmStatuses array will contain all the details for each VM, including the agent version, for the VMs that are running.