The issue of grouping devices based on attributes of their primary users – such as company name, country, etc. – often arises. We can achieve this goal using device tags, which we can then use to create dynamic groups. Attached you will find the script and instructions for implementation. In my case, the script runs in an Azure Automation account.
Step 1: Preparing your Azure Automation account
2. Installing the necessary modules
3. The script
Once the runbook has been deployed, open it once, then go to 'Edit' (either in your browser or VS Code) and import the following script:
Download Script
4. If necessary, the planned regular execution
In the runbook under Resources / Schedules, you have the option of running the script regularly, e.g. daily. To do this, simply go to "Add schedule". This could look something like this:
Click on Create at the bottom and confirm the following dialogue box with OK. The time schedule is now assigned to the script.
This completes the implementation, and we can now create corresponding device groups based on the tags. We can then use these to scope roles, assign policies, etc.
Further information is available on this page: https://learn.microsoft.com/en-us/answers/questions/2237145/invalid-jwt-access-token