Azure PS查询以获取特定于给定资源组注册的资源提供程序

时间:2019-01-18 17:49:40

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

Get-AzureRmResourceProvider -ListAvailable | Select-Object ProviderNamespace, RegistrationState

上面的PS查询可以获取所有资源提供者和注册状态。

现在,当我有添加了一些资源的资源组

是否可以编写PS / Cloud Shell查询脚本来获取仅用于特定资源组中资源的资源提供者?

2 个答案:

答案 0 :(得分:1)

just do a Get-AzResource and find all the resource types in that resource group, something like:

Get-AzResource -ResourceGroupName xxx | Select-Object ResourceType

答案 1 :(得分:1)

请尝试以下命令,$arrayList是资源组的所有资源提供者。

$a = (Get-AzureRmResource -ResourceGroupName joywebapp).ResourceType 
$arrayList = New-Object System.Collections.ArrayList
foreach($item in $a){
    if($arrayList.Contains(($item -split("/"))[0]) -eq $false){
        $arrayList.Add((($item -split("/"))[0])) | Out-Null
    }  
}

enter image description here