Azure Tags: Assistance w/ PS Scripting or ARM Template & Pipeline

Copper Contributor

I've been tasked to develop a script, or automate via other means (ARM template and pipeline for example).  The automation must do the following:

 

  1. Prompt for the Azure tenant ID and subscription ID (or Name).

  2. Prompt for Azure Credentials.

  3. Set Azure Context.

  4. Set the Tag Name and Tag Value.

  5. Get a list of all Resource Groups in that Subscription and export that list to a text file or csv.

  6. Call the Resource Group text file and for each Resource Group listed in the text file or csv, get the resource inventory in that RG, and export that RG's inventory into a separate text file which will list each resource by Name, Type, Location, Tags.

  7. Call each RG inventory text file and for each inventory item (resource) in the text file, check the Tags property and either create the Tag Name and Value (noted in #3 above), OR if it does not match the Name and value in #3, update the Tag.

I'm certain there is very likely a PowerShell script (preference) or a template and pipeline out there that can achieve the requirement, but I've yet to find one.

 

I have started working on a basic PowerShell script (below) to get the nuts and bolts in there while testing the latest AZ commands, and it works, but now I must build the logic in the script to automate #'s 5 - 7 above.

0 Replies