
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Change Azure Tag Value Using PowerShell
To change the azure value using PowerShell we need to use the Update-AZTag command with the merge property.
Example
For 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 Tags
Output
Key Value --- ----- Owner Chirag For Ansible Patching_Day Sunday Application SecretTag
We 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 -Verbose
Output
Name Value ============ ========= Patching_Day Wednesday For Ansible Application SecretTag Owner Chirag
There is also property Replace available in Update-AZTag but please be cautious while using the Replace parameter because once you apply it, the current tag will be changed but other tags will be erased.
Example
Update-AzTag -Tag $tag -ResourceId $vm.Id -Operation Replace -Verbose
Output
Properties : Name Value ============ ========= Patching_Day Wednesday
Advertisements