I need to use some Dynatrace APIs to retrieve a list of all host groups names configured in our environment,
i do not have host group ids and i do not want to retrieve a single host or host group, simply a full list of ALL distinct host groups names, and their ids in case host groups also have IDs.
what is the easiest set of APIs to use to retrieve this list?
I have an equally good solution. Someone had created an amazing set of powershell scripts to also extract administrative type data out of DT. The Git Repo is here: https://github.com/mzball-dt/dynatrace-pwsh
Note: Each script has a helpful header that tells you what permissions the token requires, the parameters you can pass in, and some example runs
First create a token with the proper access to run the script. You'll need it in Step 5
Steps for DT SaaS. If you use Managed then follow the instruction in the Git repo.
1) downloaded and extract the zip
2) Open a powershell prompt (e.g. C:\dynatrace-pwsh-master)
3) navigate to the directory you extracted the code into
4) Enter (replace xxxxx with your SaaS tenant id)
6) Enter this command and enter 'Y'. This changes the execution policy so that you can run third-party scripts.
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass;
7) Run any of the scripts you like.
Here are example commands I use frequently to get the data
C:\dynatrace-pwsh-master\get-tenantHostGroupDetail.ps1 -token dt0c01.xxxxxx -dtenv https://xxxxx.live.dynatrace.com -outfile hostgroup_06092021.csv C:\dynatrace-pwsh-master\get-tenantHostGroupDetail.ps1 | format-table C:\dynatrace-pwsh-master\get-tenantHostGroupDetail.ps1 -token dt0c01.xxxxxxxx -dtenv https://xxxxxxx.live.dynatrace.com -summary