Forum Discussion
nathan_mitten_rpa
Dec 23, 2019Copper Contributor
VM Agent Status and Version Reporting
Hello, I'm trying to see if there is anyway to pull information that is listed in the portal via PS/CLI/API/Graph across subscriptions. I'm specifically looking for the current "Agent Status" and...
- 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.
david1718
Feb 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
hspinto
Microsoft
Feb 23, 2022
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.
- david1718Feb 23, 2022Copper ContributorThanks alot it worked!