manifests/collectors/Security/DefenderSecureScore.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Security/DefenderSecureScore.ps1 (AB#5660).
# Field expressions are copied verbatim from the original collector and evaluate in an
# equivalent scope -- see docs/design/decisions/declarative-collectors.md.
# Review before trusting; regenerate rather than hand-patch if the source collector changes.
#
@{
    ResourceTypes = @(
        'AZSC/Subscription/SecurityPolicySweep'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    RowSource = @{
        Expression = @'
foreach ($sweep in @($Resources | Where-Object { $_.TYPE -eq 'AZSC/Subscription/SecurityPolicySweep' })) {
            foreach ($score in @($sweep.PROPERTIES.DefenderSecureScores)) {
                $score | Add-Member -NotePropertyName 'SubscriptionId' -NotePropertyValue $sweep.subscriptionId -Force -PassThru
            }
        }
'@

    }

    Preamble = @'
$ResUCount = 1
                $sub1 = $SUB | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'Id') -eq (Get-AZSCSafeProperty -InputObject $1 -Path 'SubscriptionId') } | Select-Object -First 1
                $data = $1
 
                # Calculate score percentage
                $currentScoreValue = Get-AZSCSafeProperty -InputObject $data -Path 'Score.Current'
                $maxScoreValue = Get-AZSCSafeProperty -InputObject $data -Path 'Score.Max'
                $currentScore = if ($currentScoreValue) { [math]::Round($currentScoreValue, 2) } else { 0 }
                $maxScore = if ($maxScoreValue) { [math]::Round($maxScoreValue, 2) } else { 0 }
                $scorePercentage = if ($maxScore -gt 0) {
                    [math]::Round(($currentScore / $maxScore) * 100, 2)
                } else { 0 }
'@


    AdditionalRowLoops = @()

    TagLoop = $null

    Fields = @(
        @{
            Name = 'ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $1 -Path ''Name'''
        }
        @{
            Name = 'Subscription'
            Expression = 'Get-AZSCSafeProperty -InputObject $sub1 -Path ''Name'''
        }
        @{
            Name = 'Secure Score Name'
            Expression = 'Get-AZSCSafeProperty -InputObject $data -Path ''DisplayName'''
        }
        @{
            Name = 'Current Score'
            Expression = '$currentScore'
        }
        @{
            Name = 'Max Score'
            Expression = '$maxScore'
        }
        @{
            Name = 'Score Percentage'
            Expression = '"$scorePercentage%"'
        }
        @{
            Name = 'Healthy Resources'
            Expression = 'if (Get-AZSCSafeProperty -InputObject $data -Path ''Score.HealthyResourceCount'') { Get-AZSCSafeProperty -InputObject $data -Path ''Score.HealthyResourceCount'' } else { 0 }'
        }
        @{
            Name = 'Unhealthy Resources'
            Expression = 'if (Get-AZSCSafeProperty -InputObject $data -Path ''Score.UnhealthyResourceCount'') { Get-AZSCSafeProperty -InputObject $data -Path ''Score.UnhealthyResourceCount'' } else { 0 }'
        }
        @{
            Name = 'Not Applicable Resources'
            Expression = 'if (Get-AZSCSafeProperty -InputObject $data -Path ''Score.NotApplicableResourceCount'') { Get-AZSCSafeProperty -InputObject $data -Path ''Score.NotApplicableResourceCount'' } else { 0 }'
        }
        @{
            Name = 'Weight'
            Expression = 'if (Get-AZSCSafeProperty -InputObject $data -Path ''Weight'') { Get-AZSCSafeProperty -InputObject $data -Path ''Weight'' } else { ''N/A'' }'
        }
        @{
            Name = 'Portal Link'
            Expression = '"https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/SecureScore"'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
    )

    Export = @{
        WorksheetName = 'Defender Secure Score'
        TableNamePrefix = 'DefenderScoreTable_'
        Columns = @(
            'Subscription'
            'Secure Score Name'
            'Current Score'
            'Max Score'
            'Score Percentage'
            'Healthy Resources'
            'Unhealthy Resources'
            'Not Applicable Resources'
            'Weight'
            'Portal Link'
            'Resource U'
        )
        TagColumns = @()
        TagColumnsBefore = $null
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText -ConditionalType LessThan -Text ''50'' -Range F:F -BackgroundColor ''#FFC7CE'' -ConditionalTextColor ''#9C0006'''
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Security/DefenderSecureScore.ps1'
}