Search code examples
azurepowershellazure-powershellazure-clipowershell-cmdlet

Get extended information on Azure Advisor recommendations via Powershell


I'm trying to use Get-AzAdvisorRecommendation command for automatic sending of emails to users, that appear in Advisor's alerts. Issue being, that Get-AzAdvisorRecommendation command does not show the actual description of the recommendation, like "Right-size or shutdown underutilized virtual machines" in the output. It only gives vague information like "ShortDescription: Microsoft.Azure.Commands.Advisor.Cmdlets.Models.PsRecommendationBaseShortDescription" and RecommendationTypeID. Azure CLI "az advisor recommendation list" command does provide the information under "shortDescription" value. Is there any way to get the same information using Get-AzAdvisorRecommendation command?


Solution

  • Indeed. ShortDescription is returned in the response as a nested property. You can access it as follows:

    Get-AzAdvisorRecommendation | Select-Object RecommendationTypeId, @{Name="ShortDescription"; Expression={$_.ShortDescription.Problem}}
    

    Include (select) other properties as needed.