Skip to content

Instantly share code, notes, and snippets.

@tylergohl
Last active February 10, 2017 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylergohl/5e14e5b554d83ec9900583dec2ae8844 to your computer and use it in GitHub Desktop.
Save tylergohl/5e14e5b554d83ec9900583dec2ae8844 to your computer and use it in GitHub Desktop.
Updates Azure RM VM tags in bulk. Retain current tags.
$TestVMs = Get-AzureRMVM | where ResourceGroupName -like test*
ForEach ($VM in $TestVMs) {
$CurrentTags = $VM.Tags
Write-Verbose "VM name: $VM.Name"
Write-Verbose "Current tags: $CurrentTags"
$VM | Update-AzureRMVm -tags ($CurrentTags += @{yournewtag="yournewvalue"}) -ErrorAction Continue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment