Powershell is somewhat tedious to work with, with the azurerm module. For e.g., ‘get-azurermwebapp’, you can’t filter or select based off of site name.

Another thing is that the above command doesn’t display which app service plan a webapp is part of. Well, it does, but it’s the full subscription ID of it, not just the name.

Regex that with the below:

  
$rgs = get-azurermresourcegroup
  
$array = @()
  
foreach ($rg in $rgs)
      
{
      
$things = get-azurermwebapp -ResourceGroupName $rg.ResourceGroupName
      
$plans = get-azurermappserviceplan -resourcegroupname $rg.ResourceGroupName
      
foreach ($thing in $things)
          
{
          
$serverfarm = ($thing.serverfarmid | select-string -Pattern "\/(?:.(?!\/))+$").matches.Value
          
$obj = new-object System.Object
          
$obj | add-member -MemberType NoteProperty -Name "Webname" -Value $thing.Name
          
$obj | add-member -MemberType NoteProperty -Name "AppSvcPlan" -Value $serverfarm
          
$obj | add-member -MemberType NoteProperty -Name "ResourceGroup" -Value $rg.ResourceGroupName
          
$array += $obj
      
}
  
$array