1
votes

Recently I update Azure Powershell modules in Azure Automation Account and it seems that with new version of AzureRm.Resources module the way of dealing with tags on resources and resource group changes. Previously this is how I would list resource groups with AutoShutdownSchedule tag name

(Get-AzureRmResourceGroup | where {$_.Tags.Name -contains "AutoShutdownSchedule"}

Now according to https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-using-tags I have to use:

Find-AzureRmResourceGroup -Tag @{Name="AutoShutDownSchedule"}

But this doesn't return anything. However Find-AzureRmResourceGroup is working:

    Find-AzureRmResourceGroup


id         : /subscriptions/xxxxx/resourceGroups/HaaS-CDH-Starter-Spotfire-1393
name       : xxxxx
location   : eastus2
tags       : @{AutoShutdownSchedule=18:00}
properties : @{provisioningState=Succeeded}

id         : /subscriptions/xxxxxx/resourceGroups/mnt-dev-us
name       : xxxx
location   : eastus2
tags       : @{AutoShutdownSchedule=18:00}
properties : @{provisioningState=Succeeded}

Any suggestions what I'm doing wrong?

1
If my answer helps resolved your question and if you do appreciate the effort in helping, please mark the answer as acceptable answer.juvchan

1 Answers

1
votes

You should use the command below to get the resource group(s) for the tag with name of AutoShutdownSchedule.

Find-AzureRmResourceGroup -Tag @{ AutoShutdownSchedule = $null }

The example of Find Resource Group(s) by tag name for Find-AzureRmResourceGroup cmdlet can be obtained from:

get-help Find-AzureRmResourceGroup -full
--------------------------  FindByTagName  --------------------------

Find-AzureRmResourceGroup -Tag @{ testtag = $null }

Finds all resource group with a tag with name 'testtag'.

Note: Verified working with AzureRm.Resources module version: 3.5.0