Hi Guys,
below script gives me out put of tags in csv in below format (all values and keys in a single column)
| VALUE1:VALUE2:VALUE3:KEY1:KEY2:KEY3 |
| VALUE1 | KEY1 | VALUE2 | KEY2 | VALUE3 | KEY3 |
$subs = Get-AzureRmSubscription
$allResources = @()
foreach ($sub in $subs)
{
Select-AzureRmSubscription -SubscriptionId $sub.SubscriptionId
$resources = Get-AzureRmResource
foreach ($resource in $resources)
{
$customPsObject = New-Object -TypeName PsObject
$subscription = Get-AzureRmSubscription -SubscriptionId $resource.SubscriptionId
$tags = $resource.Tags.Keys + $resource.Tags.Values -join ':'
$customPsObject | Add-Member -MemberType NoteProperty -Name ResourceName -Value $resource.Name
$customPsObject | Add-Member -MemberType NoteProperty -Name ResourceGroup -Value $resource.ResourceGroupName
$customPsObject | Add-Member -MemberType NoteProperty -Name ResourceType -Value $resource.ResourceType
$customPsObject | Add-Member -MemberType NoteProperty -Name Kind -Value $resource.Kind
$customPsObject | Add-Member -MemberType NoteProperty -Name Location -Value $resource.Location
$customPsObject | Add-Member -MemberType NoteProperty -Name Tags -Value $tags
$customPsObject | Add-Member -MemberType NoteProperty -Name Sku -Value $resource.Sku
$customPsObject | Add-Member -MemberType NoteProperty -Name ResourceId -Value $resource.ResourceId
$customPsObject | Add-Member -MemberType NoteProperty -Name Subscription -Value $subscription.Name
$allResources += $customPsObject
}
}
$allResources | Export-Csv -Path C:\temp\resource-audit.csv -NoTypeInformation