- 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 Export the azure VM tags using PowerShell?
There are two ways to get the applied azure VM tags using PowerShell.
- Using Tags Property of the Azure VM
- Using the Get-AZTag command.
Example
PS C:\> Get-AzVM -VMName Testmachine2k12 | Select -ExpandProperty Tags Key Value --- ----- Patching_Day Sunday Owner Chirag
Another way is by using the Get-AZTag command.
PS C:\> $vm = Get-AzVM -VMName TestMachine2k12 PS C:\> Get-AzTag -ResourceId $vm.Id | Select -ExpandProperty Properties
Output
TagsProperty ------------ {[Owner, Chirag], [Patching_Day, Sunday]}
We need to export this tag and the best way to store the tags is using the JSON file.
Get-AzVM -VMName Testmachine2k12 | Select -ExpandProperty Tags | ConvertTo-Json | Out-File C:\Temp\VMTag.json
You can see the tag file is stored in the C:\temp folder with the VMTag.json file name.
If you want to store the tags in the CSV file format then, we can use the below command.
Get-AzVM -VMName TestMachine2k16 | Select -ExpandProperty Tags | ConvertTo-Json | ConvertFrom-Json | Export-Csv C:\Temp\TestMachine2k16tags.csv -NoTypeInformation
The above command will store the azure VM TestMachine2k16 tags to the C:\Temp\TestMachine2k16tags.CSV format.
- Related Articles
- How to Export the Azure VMs using PowerShell?
- How to deallocate the Azure VM using Azure CLI in PowerShell?
- How to start the Azure VM using Azure CLI in PowerShell?
- How to stop the Azure VM using Azure CLI in PowerShell?
- How to restart the Azure VM using Azure CLI in PowerShell?
- How to resize the Azure VM using Azure CLI in 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 list the azure VM extensions using Azure CLI in PowerShell?
- How to add the tag of Azure VM using PowerShell?
- How to get the Azure VM available sizes using PowerShell?
- How to get the installed Azure VM extension using PowerShell?
- How to enable the Azure VM accelerated settings using PowerShell?
- How to disable the Azure VM accelerated settings using PowerShell?
- How to retrieve the Azure VM deallocated date using PowerShell?

Advertisements