One of the things that the powershell command does not do is list out the tags in a way that is easy to consume in a report format. In this blog post, I'll show a quick script that you can use to create a quick and easy report.
$resources = Get-AzureRmResource $resourcesToDisplay = @() foreach ($resource in $resources){ $props = @{ 'name'=$resource.Name 'resourceGroup'=$resource.resourceGroupName; 'owner'="MISSING"; 'department'="MISSING"; 'approved'="MISSING"; } $tags = $resource.tags if ($tags){ foreach ($key in $tags.keys){ $props.$key = $tags[$key] } } $obj = new-Object PSObject -Property $props $resourcesToDisplay += $obj } $resourcesToDisplay | Select-object name, resourceGroup, owner, department, approved | ft
The script above is pretty simple, but gets the job done for now. Enjoy!
No comments:
Post a Comment