Skip to content

How to Fetch Impacted resources from Azure recommendations through PowerShell script #15767

Answered by dcaro
Mo5zzz asked this question in Q&A
Discussion options

You must be logged in to vote

@Mo5zzz, I am not sure about your goal but the following code that may help you. It returns the list of KeyVaults that have a recommendation:

Get-AzAdvisorRecommendation | Where-object { $_.ImpactedField -eq "Microsoft.KeyVault/vaults" } | ForEach-Object { Get-AzResource -ResourceType $_.ImpactedField -Name $_.ImpactedValue } | Sort-Object -Property Name -Unique

Note: the Sort-Object command deduplicate entries in the output in the case a resource has more than one recommendation.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dingmeng-xue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants