Need Query or Other option to see how many VM's does not have AzureMonitorWindowsAgent extension installed ?

Shailesh Chauhan 0 Reputation points
2025-05-05T16:55:38.4966667+00:00

I Need help to get list of VM which does not have AzureMonitorWindowsAgent extension installed ?

Is there any Kusto or resource graph query or any other way we can confirm ?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,760 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Divyesh Govaerdhanan 3,730 Reputation points
    2025-05-05T20:04:16.13+00:00

    Hello,

    Welcome to Microsoft Q&A,

    You could use the below PowerShell command to see the VMs that do not have this extension enabled.

    $vms = Get-AzVM
    foreach ($vm in $vms) {
        $extensions = Get-AzVMExtension -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name -ErrorAction SilentlyContinue
        if ($extensions.Name -notcontains "AzureMonitorWindowsAgent") {
            Write-Output "$($vm.Name) in $($vm.ResourceGroupName) does NOT have AzureMonitorWindowsAgent"
        }
    }
    
    
    

    Please Upvote and accept the answer if it helps!!


  2. Markapuram Sudheer Reddy 1,675 Reputation points Microsoft External Staff
    2025-05-06T02:40:16.2066667+00:00

    Hi Shailesh Chauhan,

    Open Resource Graph Explorer in Azure and run a below query to know about the VM extension and its Provisioning State.

    resources
    | where type == "microsoft.compute/virtualmachines/extensions"
    | extend VMName = split(id, "/")[8] 
    | where name has "<name of the extension>"
    | extend SubscriptionName = case(
        subscriptionId == '<your subscription id>', 
        '<your subscription name>', 
        subscriptionId
    )
    | project VMName, AgentName=name, SubscriptionName, ProvisioningState=properties.provisioningState
    

    The above query will return the extension along with its provisioning state.

    I tried below query in my lab environment to check the status of different extensions and its Provisioning State:User's image

    User's image

    If the information is helpful, please click on "Accept Answer" and "Upvote"

    If you have any queries, please do let us know, we will help you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.