Search code examples
azurepowershellazure-resource-managerazure-cliazure-resource-group

Azure PS query to obtain resource providers registered specific to a given resource group


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

The above PS query can get me all the resource providers and registered state.

Now, when I have resource-group with a few resources added

Is it possible to script a PS/Cloud Shell query to get the resource providers needed for just the resources in that specific resource group ?


Solution

  • Try the command below, the $arrayList is all the resource providers of the resource group.

    $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