按标记名称查找Azure资源组

时间:2017-01-31 12:30:09

标签: azure azure-powershell azure-resource-group

最近,我更新了Azure自动化帐户中的Azure Powershell模块,似乎使用新版本的AzureRm.Resources模块处理资源和资源组更改上的标记。 以前这是我用AutoShutdownSchedule标记名

列出资源组的方法
(Get-AzureRmResourceGroup | where {$_.Tags.Name -contains "AutoShutdownSchedule"}

现在根据https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-using-tags我必须使用:

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

但这并不能归还任何东西。但是,Find-AzureRmResourceGroup正在运行:

    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}

有什么建议我做错了吗?

1 个答案:

答案 0 :(得分:1)

您应该使用以下命令获取名称为 AutoShutdownSchedule 的标记的资源组。

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

可以从以下位置获取Find-AzureRmResourceGroup cmdlet的标记名称查找资源组的示例:

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

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

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

注意:已验证使用AzureRm.Resources模块版本: 3.5.0

相关问题