Skip to content

Instantly share code, notes, and snippets.

@lukemurraynz
Created October 1, 2023 05:25
Show Gist options
  • Save lukemurraynz/dcb4887d7336f214812d27f2c28ddfe9 to your computer and use it in GitHub Desktop.
Save lukemurraynz/dcb4887d7336f214812d27f2c28ddfe9 to your computer and use it in GitHub Desktop.
#Hidden Tags demo
# Check with AzTags
Get-AzTag
# Add a tag to a resource demo
$replacedTags = @{"hidden-title" = "Web Server"; "hidden-ShutdownAutomation" = "Yes"}
$resouceGroup = 'hiddentags-demo'
Get-AzResource -ResourceGroupName $resouceGroup | Select-Object ResourceId | Out-GridView -PassThru | Update-AzTag -Tag $replacedTags -Operation Merge
# Get resources with a specific tag name demo
# Set the tag name to search for
$tagName = "Hidden-Title"
# Get all resources with the specified tag name
$resources = Get-AzResource -TagName $tagName
# Output the results
foreach ($resource in $resources) {
Write-Output "Resource Name: $($resource.Name)"
Write-Output "Resource Type: $($resource.ResourceType)"
Write-Output "Resource Location: $($resource.Location)"
Write-Output ""
}
# Bicep example
param resourceTags object = {
hidden-title: 'Web Server'
hidden-ShutdownAutomation: 'Yes'
}
tags: resourceTags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment