Forum Discussion

nathan_mitten_rpa's avatar
nathan_mitten_rpa
Copper Contributor
Dec 23, 2019
Solved

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 version seen here:

 

 

From what I can find the information in the OSProfile property does not always exist depending on how the VM was deployed and even when it does, it only lists True, not the status or the version.

 

Thanks,

 

Nathan

 

  • 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.

5 Replies

  • 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's avatar
      david1718
      Copper 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's avatar
        hspinto
        Icon for Microsoft rankMicrosoft

        david1718 

         

        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.

Resources