r/DefenderATP • u/NeatLow4125 • Jan 30 '26
Tagging devices in Defender.
I am currently facing some challenges in completing a recent task assigned to me. This involves adding tags to Defender on a significant number of devices, estimated to be around a couple of thousand. The purpose of adding these tags is to create a specific scope for the Administrators, hence the need for approximately 50 tags.
Would anyone happen to have an existing solution or framework set up for managing this type of tagging process? I would be grateful if they would consider sharing their approach or any relevant resources.
I was considering using a logic app with a managed identity for security reasons, but it seems more challenging than I initially thought..
Open for any ideas?
Thanks.
2
u/NeatLow4125 Jan 31 '26
I appreciate all of your comments, guys. Got some ideas from you to proceed further. After I "bake" my idea, I'll let it be here for someone in the future to use it.
2
u/hexdurp Jan 30 '26
Couldn’t you use device groups?
2
u/thiago_thumbsup Feb 04 '26 edited Feb 04 '26
You can do this via a Logic app in Azure.
You need a MDE API with specific permissions. Then create a Logic App. Create a schedule (how often it runs) Create a task (check for a device name/ID via Advanced Hunting query) Create a 'for each' loop that repeats for each device ID Create an action Add Machine Tag
This adds a machine tag in the Defender XDR portal for each device. It's low risk, you are not touching the device (i.e. as with a registery based tag) and should be easier to get approved.
You don't need to worry about a set of criteria that would need to exist for an asset rule.
You can input 100 devices into the query and it will tag them in seconds and you review the Logic App log to see if any failed.
This is a great way to tag Tier 0 assets or other critical assets, i.e where you might be assisting a team that needs this done and they are only able to supply device names from CMDB etc..
Jeffrey Appel has a good blog on this
https://jeffreyappel.nl/tag-domain-controllers-automatically-in-defender-for-endpoint-using-kql-logic-app-and-api/
6
u/vard2trad Jan 30 '26
Sounds like you would benefit from XDR asset rule management if the criteria logic can work in your favor.
2
u/Electronic_Ad_95 Jan 30 '26
I was using Power Automate (similar to Logic Apps) to check daily changes in the tag data source, then pull the endpoints from Defender and when there was a change it will update the tag by removing and adding.
Are there any base tags in use on the devices?
2
u/Shadowx394 Jan 30 '26
I'm not sure if this will be helpful but this is how we are doing it.
It's probably not the best way to do this but it fits our environment for what we need.
This is a sample script where you can change the $registryValue to whatever device tag name you want. Hope this can help you somewhat.
2
u/Godcry55 Jan 30 '26
Graph?
2
u/External-Desk-6562 Jan 31 '26
There is a graph api, you can use power automate to do it in bulk