manifests/collectors/Security/KeyVaultSecrets.psd1

#
# GENERATED by scripts/Build-ScoutServiceCollector.ps1 from manifests/specs/service-collectors.psd1 (AB#6741).
# Authored as data -- there is no source collector script to drift from. Edit the spec and
# regenerate; do not hand-patch this file.
#
@{
    ResourceTypes = @(
        'AZSC/ARMChild/KeyVaultSecrets'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
                $data = $1.PROPERTIES
                $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId }
                $SecretName = if([string]::IsNullOrEmpty($1.name)){$null}else{(([string]$1.name) -split '/')[-1]}
                $Kind = if($data.contentType -match 'x-pkcs12|x-pem-file'){'Certificate'}else{'Secret'}
                $Expires = if($null -eq $data.attributes.exp){''}else{[string]([datetime]::UnixEpoch).AddSeconds([double]$data.attributes.exp).ToString('yyyy-MM-dd')}
                $DaysToExpiry = if($null -eq $data.attributes.exp){$null}else{[math]::Floor(((([datetime]::UnixEpoch).AddSeconds([double]$data.attributes.exp)) - $ScoutRunTime).TotalDays)}
                $ExpiryStatus = if($null -eq $DaysToExpiry){'No expiry set'}elseif($DaysToExpiry -lt 0){'EXPIRED'}elseif($DaysToExpiry -le 30){'Expires within 30 days'}elseif($DaysToExpiry -le 90){'Expires within 90 days'}else{'OK'}
                $NotBefore = if($null -eq $data.attributes.nbf){''}else{[string]([datetime]::UnixEpoch).AddSeconds([double]$data.attributes.nbf).ToString('yyyy-MM-dd')}
                $Created = if($null -eq $data.attributes.created){''}else{[string]([datetime]::UnixEpoch).AddSeconds([double]$data.attributes.created).ToString('yyyy-MM-dd')}
                $Updated = if($null -eq $data.attributes.updated){''}else{[string]([datetime]::UnixEpoch).AddSeconds([double]$data.attributes.updated).ToString('yyyy-MM-dd')}
'@


    AdditionalRowLoops = @()

    TagLoop = $null

    Fields = @(
        @{
            Name = 'ID'
            Expression = '$1.id'
        }
        @{
            Name = 'Subscription'
            Expression = '$sub1.Name'
        }
        @{
            Name = 'Resource Group'
            Expression = '$1.RESOURCEGROUP'
        }
        @{
            Name = 'Key Vault'
            Expression = '$1.PARENTNAME'
        }
        @{
            Name = 'Secret'
            Expression = '$SecretName'
        }
        @{
            Name = 'Content Type'
            Expression = '$data.contentType'
        }
        @{
            Name = 'Kind'
            Expression = '$Kind'
        }
        @{
            Name = 'Enabled'
            Expression = '[string]$data.attributes.enabled'
        }
        @{
            Name = 'Expires'
            Expression = '$Expires'
        }
        @{
            Name = 'Days To Expiry'
            Expression = '[string]$DaysToExpiry'
        }
        @{
            Name = 'Expiry Status'
            Expression = '$ExpiryStatus'
        }
        @{
            Name = 'Not Before'
            Expression = '$NotBefore'
        }
        @{
            Name = 'Created'
            Expression = '$Created'
        }
        @{
            Name = 'Updated'
            Expression = '$Updated'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
    )

    Export = @{
        WorksheetName = 'Key Vault Secrets'
        TableNamePrefix = 'KeyVaultSecretsTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Key Vault'
            'Secret'
            'Content Type'
            'Kind'
            'Enabled'
            'Expires'
            'Days To Expiry'
            'Expiry Status'
            'Not Before'
            'Created'
            'Updated'
            'Resource U'
        )
        TagColumns = @()
        NumberFormat = '0'
        ConditionalText = @()
    }
}