Sunday, May 6, 2018

CIS Control 1 on Azure - Maintain Asset Inventory Part 2

In a previous post I talked a little bit about CIS Control 1 and, specifically, 1.5 - Maintain Asset Inventory Information.  We explored how to use the portal to retrieve most of the information you would need to satisfy the control.  At the end of that post, I showed a quick example of how to do the same in powershell.

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 = @{

    $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