Hi, I'm Nicholas 👋

I'm a Senior Platform Engineer

Buy Me A Coffee

How to tag Azure Resources using Powershell

Date published:

Tagging resources is a great way to organize your resources and make it easier to find them. You can also use tags to apply policies to resources. For example, you can use tags to apply a retention policy to all resources with a specific tag. This post will show how to use PowerShell to tag Azure Resources.

We will use the following resources to demonstrate how to tag resources using PowerShell.

We will tag all the resources in the resource group with the following tags.

  1. Log in to Azure using PowerShell on your local machine
  1. Assign a variable for the resource group name
  1. Next, set the tags for the resource group

  1. Confirm the resource group and tags value. After, we will use it on all the resources within the resource group.

Get-AzResourceGroup -Name tag-resources-powershell | Select-Object ResourceGroupName, @{Name=“Tags”;Expression={$_.Tags}}

When running the command, all the resources will have the tag with the values we set in step 3.

I hope you enjoy this post. If you have any questions or comments, please leave them below.