Reputation: 806
This Is what I would like to. with powershell (or Az cli) Get a list of ALL my resources in azure with the name of the resource, type and tag with key pair exported in an excel like following example, and only bring information if tag value is some particular that I declare in command.
For example: bring all my azure resources if value of tag3=value3
name type tag1 tag2 tag3
VM1 v.mach value1 value2 value3
webapp2 wapp ValueX Value85 value3
disk8 disk valueF value89 value3
result I would like to bring it in a csv file. I know this is done with at the end of command:
| Export-Csv -Path "C:\Windows\azureinventory.csv"
but right now I can´t bring results with tag separated.
I tried following command but tag column brings value on same column. Would like to get them separated like in first example:
Get-AzureRmResource -TagName "LifeTime" | where { $_.Tags['LifeTime'] -eq "20170503" } | Select-Object -Unique Name, Type, tags
Upvotes: 0
Views: 1744
Reputation: 12153
Try this :
Get-AzureRmResource | Select-Object -Property name , type , @{N='tag1'; E={$_.Tags.tag1}} ,@{N='tag2'; E={$_.Tags.tag2}}
Hope it helps .
Upvotes: 1