# Extracting a Flexera AgentUniqueID from Hosts

**URL:** <https://community.dynatrace.com/t/extracting-a-flexera-agentuniqueid-from-hosts/48596>\
**Category:** Open Q&A\
**Tags:** tagging, infrastructure-operations\
**Created:** [October 28, 2024, 10:08pm UTC](https://community.dynatrace.com/t/extracting-a-flexera-agentuniqueid-from-hosts/48596 "2024-10-28T22:08:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AntonGoosen](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antongoosen/32/29737_2.png) [@AntonGoosen](https://community.dynatrace.com/u/AntonGoosen)\
**Post date:** [October 28, 2024, 10:08pm UTC](https://community.dynatrace.com/t/extracting-a-flexera-agentuniqueid-from-hosts/48596/1 "2024-10-28T22:08:38Z")

</div>

Hi there.

I want to&nbsp;Extract the Flexera AgentUniqueID from the config.ini file of all the Hosts in my env and assign it to the Host in DT as a Tag.&nbsp; I can easily get the ID from ssh in Linux:

---------------------------  
sudo grep -r “AgentUniqueID” /var/opt/managesoft/etc/config.ini

The result is:

---------------------------

[ManageSoft\AgentUniqueID]  
AgentUniqueID=a96abfc1ababc16bb7190ffaf965336ca7df1814dcf2c24ac3

---------------------------

Is there an easier way to do this via another mechanism?

---

<div class="post-metadata">

**Author:** ![MostafaHussein](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mostafahussein/32/2785_2.png) [@MostafaHussein](https://community.dynatrace.com/u/MostafaHussein)\
**Post date:** [October 28, 2024, 10:53pm UTC](https://community.dynatrace.com/t/extracting-a-flexera-agentuniqueid-from-hosts/48596/2 "2024-10-28T22:53:16Z")

</div>

you can use the following bash script as it automate extraction to a variable then use oneagentctl to reset assigned property or tag by removing it if exists then set the new value (you can change the oneagentctl to set property not tags according to your needs).

this on each host individually or within batch for your cluster

```markup
#!/bin/bash

# Get the AgentUniqueID from the config file
agent_unique_id=$(sudo grep -Po '(?<=AgentUniqueID=).*' /var/opt/managesoft/etc/config.ini)

# Check if the AgentUniqueID was found
if [[-z "$agent_unique_id"]]; then
    echo "AgentUniqueID not found in config file."
    exit 1
fi

# Remove the existing AgentUniqueID property
./oneagentctl --remove-host-tag=AgentUniqueID

# Set the new AgentUniqueID property
./oneagentctl --set-host-tag=AgentUniqueID="$agent_unique_id"

echo "AgentUniqueID updated successfully."

```

references:

> **[OneAgent configuration via command-line interface](https://docs.dynatrace.com/docs/ingest-from/dynatrace-oneagent/oneagent-configuration-via-command-line-interface)**
>
> Learn how to perform some OneAgent configuration tasks without the need to reinstall OneAgent.

> **[Define tags and metadata for hosts](https://docs.dynatrace.com/docs/observe/infrastructure-observability/hosts/configuration/define-tags-and-metadata-for-hosts)**
>
> Automate host tags and metadata with oneagentctl or configuration files, and use the resulting properties in auto-tagging and management-zone rules.

hope this helpful for you.

BR,  
Mostafa Hussein.
