首页 文章

按标记名称查找Azure资源组

提问于
浏览
1

最近我更新了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 回答

  • 1

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

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

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

    get-help Find-AzureRmResourceGroup -full
    

    -------------------------- FindByTagName ---------------------- ----

    Find-AzureRmResourceGroup -Tag @

    查找名称为“testtag”的标记的所有资源组 .

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

相关问题