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,813 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Divyesh Govaerdhanan 4,430 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,835 Reputation points Microsoft External Staff Moderator
    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.


  3. Pramidha Yathipathi 770 Reputation points Microsoft External Staff Moderator
    2025-05-06T13:39:47.4366667+00:00

    Hi Shailesh Chauhan,

    To identify all virtual machines in your environment that do not have the Azure Monitor Windows Agent (AzureMonitorWindowsAgent) extension installed, you can run the following Kusto Query Language (KQL) query in Azure Resource Graph Explorer:

    Resources
    | where type == "microsoft.compute/virtualmachines"
    | extend extensions = properties.extensions
    | mv-expand extensions
    | extend extensionName = tostring(extensions.name)
    | summarize hasAgent = any(extensionName == "AzureMonitorWindowsAgent") by name, resourceGroup, location
    | where hasAgent == false
    

    If you found information helpful, please click "Upvote" and "Accept answer" on the post to let us know.

    If the issue still persist feel free to ask we are happy to assist you.

    Thank You.

    0 comments No comments

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.