Creating a computer group as a function

Creating a computer group as a function


To use Machine Groups in our Automation Account inventory we must first create a group by saving a kql query as a function.


– Azure Subscription – if you do not already have a subscription, you can get a free trial here

– Log Analytics workspace configured (See here)

– Automation Account configured (See here)

In this example we will create a computer group based on Active Directory group membership.


To be able to query for Active Directory group membership we must make sure we collect the information. To do so we enable import of “Active Directory group membership from computer” under Computer groups in our Log Analytics workspace.


Create Computer group query

To create our query, we click the log icon, and this will take us to a predefined query that we can edit or built on


The default query looks as follows and shows us the groups we have in Active Directory


Now we can modify it slightly and we can get all the machines in a particular group:


Once we have the right query we save it as a function



NOTE: To be able to save the function as a computer group the distinct operator must be set to computer

Once the query is saved, we are done.


We should now be able to see our new computer group available under Machine Groups in the Automation Account inventory


More information about computer groups can be found here:

Happy testing!

Table of Contents

Share this post
Search blog posts
Modern Workplace consultant and a Microsoft MVP in Enterprise Mobility.
Modern Workplace consultant and a Microsoft MVP in Windows and Devices for IT.

Infrastructure architect with focus on Modern Workplace and Microsoft 365 security.

Cloud & security specialist with focus on Microsoft backend products and cloud technologies.

Cloud & Security Specialist, with a passion for all things Cybersecurity

Cloud and infrastructure security specialist with background in networking.

Infrastructure architect with focus on design, implementation, migration and consolidation.

Infrastructure consultant with focus on cloud solutions in Office365 and Azure.

follow us in feedly

Follow on SoMe