- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the applied azure resource tags using PowerShell?
To get all the applied tags to the Azure resources we need to use the Get-AZTag command and need to provide ResourceID to it. For example,
We need to retrieve the Azure VM tags and we will use its resource ID.
PS C:\> $vm = Get-AzVM -Name Testmachine2k16 PS C:\> Get-AzTag -ResourceId $vm.Id
You can see the output in the properties window. Another simple method is to use the Tags property for that particular cmdlet. For example, Get-AzVM, Get-AZResourceGroup, etc use the tag property for displaying the applied tags.
PS C:\> Get-AzVM -VMName TestMachine2k16 | Select -ExpandProperty Tags Key Value --- ----- Owner Chirag For Ansible Patching_Day Sunday Application SecretTag
Similarly, to get the resource group tags, you can use either the Get-AZTag command with the ResourceID property of the resource group or the Get-AZResourceGroup command with the Tag property.
PS C:\> $rg = Get-AzResourceGroup -ResourceGroupName TestRG PS C:\> Get-AzTag -ResourceId $rg.ResourceId
Or,
PS C:\> Get-AzResourceGroup -Name TestRG | Select -ExpandProperty Tags
To search for the specific tags. We need to use -Name property of the Get-AZTag command. For example, we need to search the tag called Patching_Day then we can use the below command. It shows the Patching_Day tag from the entire subscription because we haven’t provided any specific resource or resource group.
The count property shows the number of times the tag is applied to the resources and ValuesTable and values property shows the values associated with that tag key.
PS C:\> Get-AzTag -Name Patching_Day | fl Name : Patching_Day ValuesTable : Name Count ====== ===== Sunday 2 Count : 2 Values : {Sunday}
- Related Articles
- How to delete all the tags of the azure resource using PowerShell?
- How to get the Azure resource group using Azure CLI in PowerShell?
- How to get the azure resources from the resource group using PowerShell?
- How to Export the azure VM tags using PowerShell?
- How to delete the Azure Resource Group using PowerShell?
- How to retrieve the Azure VM resource group using PowerShell?
- How to create a new Azure resource group using PowerShell?
- How to apply a tag to the azure resource group using PowerShell?
- How to get the Azure VM Size using Azure CLI in PowerShell?
- How to get the Azure VM username using Azure CLI in PowerShell?
- How to check if the Azure resource group is empty or not using PowerShell?
- How to get the available azure VM size using Azure CLI in PowerShell?
- How to get the tags of the availability set using PowerShell?
- How to get the Azure VM DNS name using PowerShell?
- How to get the Azure VM available sizes using PowerShell?
