1
votes

I need to get the Specific Azure Object with a specific Tag like Dev-Tag and Test-Tag using the command in https://docs.microsoft.com/en-us/powershell/module/az.resources/get-aztag?view=azps-5.1.0

This one is working with the Resource Group object only:

$TagName = 'Test-Tag'
Get-AzResourceGroup | Where-Object {$_.Tags.Keys -match $TagName} | OGV

But this one is failed with nothing returned:

$TagName = 'Test-Tag'
Get-AzResource | Where-Object {$_.Tags.Keys -match $TagName} | OGV

So how to rectify the code above so it can be used to export all objects with those two tags as above, not just Resource groups?

2
Hi, did you check my last comments? - A Seyam

2 Answers

1
votes

Try

Get-AzResource | Where-Object {$_.TagsTable -match $TagName} | OGV
1
votes

Another solution is

Get-AzResource | Where-Object {$_.Tags.Keys -eq $TagName} | OGV