- 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
Found 2043 Articles for Microsoft Technologies
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
629 Views
To delete all the tags of the Azure VM using PowerShell, we need to use the Remove-AZTag command.To delete the azure resource tags, we need its resource ID but before that, it is always better to take azure resource tags backup. You can search the question on the TutorialPoints site or google, Site − TutorialsPoint.com How to Export the Azure VM tags using PowerShell?To delete the azure Resource Tags, PS C:\> $vm = Get-AzVM -Name Testmachine2k16 PS C:\> Remove-AzTag -ResourceId $vm.Id -VerboseTo remove the azure resourceGroup tags, PS C:\> $rg = Get-AzResourceGroup AnsibleTestRG PS C:\> Remove-AzTag -ResourceId $rg.ResourceId -VerboseTo remove ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
5K+ Views
To retrieve the CSV file headers using PowerShell, we need to use the hidden property PSObject once we use to import the CSV file. We have a CSV file stored at the C:\temp\VMTags.csv and we need to retrieve its headers. The CSV file is as below.ABCDForPatching_DayApplicationOwnerAnsibleSundaySecretTagChiragImporting the CSV file, PS C:\> $csv = Import-Csv C:\Temp\VMTags.csv PS C:\> $csv For Patching_Day Application Owner --- ------------ ----------- ----- Ansible Sunday SecretTag ChiragExampleAccessing hidden property, PS C:\> $csv.psobjectOutputWe need to use Properties to get our values. We will get all the headers here.PS C:\> $csv.psobject.Properties | Select Name ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
3K+ Views
To convert the JSON to the CSV format we need to first use the ConvertFrom-JSON command. For example, we have already JSON file present with us at the C:\temp\VMinfo.JSON location. We will first import this file and then convert it to CSV as shown below.Get-Content C:\Temp\VMInfo.json | ConvertFrom-Json | Export-Csv C:\Temp\vminfo.csv -NoTypeInformationSuppose you have cmdlet that produces output in the hash table format as shown below.PS C:\> Get-AzVM -VMName TestMachine2k16 | Select -ExpandProperty Tags Key Value --- ----- For Ansible Patching_Day ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
1K+ Views
To change the azure value using PowerShell we need to use the Update-AZTag command with the merge property.ExampleFor example, we have the Azure VM TestMachine2k16 and we have its tags as shown below.PS C:\> $vm = Get-AzVM -VMName TestMachine2k16 PS C:\> $vm | Select -ExpandProperty TagsOutputKey Value --- ----- Owner Chirag For Ansible Patching_Day Sunday Application SecretTagWe need to change the Patching_Day from Sunday to Wednesday. We will use the below command.Example$tag = @{Patching_Day='Wednesday'} Update-AzTag -Tag $tag -ResourceId $vm.Id -Operation Merge -VerboseOutputName Value ============ ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
2K+ Views
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.IdYou 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 ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
597 Views
Like Azure VM, we can apply the azure tags to the resource group or any other resources. The tagging works on the resource ID and in azure, all the resources come with the resource ID property.To apply the tag to the azure resource group, we first need to use get the resource group details to use its resource ID. The below code shows that how we can apply the new tag to the azure resource group.ExamplePS C:\> $rg = Get-AzResourceGroup -Name AnsibleTestRG PS C:\> $tag = @{Owner='Chirag'; CostCenter='USFinance'} PS C:\> New-AZTag -ResourceId $rg.ResourceId -Tag $tag -VerboseOutput
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
282 Views
New-AZTagWhen we use the New-AZTag command, it removes all the tags from the particular resource and adds a new tag. This command is generally helpful when we are creating a new resource and we want to apply the tag for it.Update-AZTagWhen we use the Update-AZTag command, it updates, deletes, and replaces the Azure tags. We need to make sure that when we are applying the tag to any existing resource which is already tagged, the Update-AZTag command should be used otherwise New-AZTag command will remove all the previous applied tags and it will add new tags.
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
1K+ Views
To delete the specific tag of the Azure VM, we can use the Delete property of the Operation parameter in the Update-AZTag command. In the below example, we have the below tags of the Azure VM TestMachine2k12.Key Value --- ----- Patching_Day Sunday Owner ChiragWe need to delete the Patching_Day tag and for that, we also need its value. The below command will delete the specified tag from the Azure VM.PS C:\> $vm = Get-AzVM -VMName TestMachine2k12 PS C:\> $tag = @{'Patching_Day'='Sunday'} PS ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
2K+ Views
To add the tag to the Azure VM we need to use the Update-AZTag command. This command will merge the new tag to the existing tag(s) of the VM. If you are planning to add the entirely new VM tag, you can use the New-AZTag command. Once you use the New-AZTag command, other tags will be deleted for that particular VM and the New tag will be created so pls be careful with that command.We have the VM called TestMachine2k12 on Azure and there are few existing tags applied to the VM as shown below.ExampleGet-AzVM -Name TestMachine2k12 | Select -ExpandProperty ... Read More
![Chirag Nagrekar](https://www.tutorialspoint.com/assets/profiles/163503/profile/60_109370-1581658197.png)
461 Views
In the previous article, we have seen that we can export the Azure resource tags in the JSON file or CSV format. There are some cases when you rebuild your resource and you might need to restore your tags or someone with the authorized person to have azure resource access and he accidentally deletes the tags and we need to restore them. In such cases, if we have the tags backup already we can import them to the resources.In the below example, we suppose we have the Azure VM tags backup stored in the CSV file format and after rebuilding ... Read More