manifests/collectors/Management/PolicyComplianceStates.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Management/PolicyComplianceStates.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 = 'state'

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

    }

    Preamble = @'
$ResUCount = 1
                $assignmentName = if (Get-AZSCSafeProperty -InputObject $state -Path 'PolicyAssignmentName') { Get-AZSCSafeProperty -InputObject $state -Path 'PolicyAssignmentName' } else { 'N/A' }
                $policyDefName = if (Get-AZSCSafeProperty -InputObject $state -Path 'PolicyDefinitionName') { Get-AZSCSafeProperty -InputObject $state -Path 'PolicyDefinitionName' } else { 'N/A' }
'@


    AdditionalRowLoops = @()

    TagLoop = $null

    Fields = @(
        @{
            Name = 'Subscription'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''SubscriptionName'''
        }
        @{
            Name = 'Subscription ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''SubscriptionId'''
        }
        @{
            Name = 'Resource ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''ResourceId'''
        }
        @{
            Name = 'Resource Type'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''ResourceType'''
        }
        @{
            Name = 'Resource Location'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''ResourceLocation'''
        }
        @{
            Name = 'Resource Group'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''ResourceGroup'''
        }
        @{
            Name = 'Policy Assignment ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''PolicyAssignmentId'''
        }
        @{
            Name = 'Policy Assignment Name'
            Expression = '$assignmentName'
        }
        @{
            Name = 'Policy Definition ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''PolicyDefinitionId'''
        }
        @{
            Name = 'Policy Definition Name'
            Expression = '$policyDefName'
        }
        @{
            Name = 'Policy Set Definition ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''PolicySetDefinitionId'''
        }
        @{
            Name = 'Compliance State'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''ComplianceState'''
        }
        @{
            Name = 'Is Compliant'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''IsCompliant'''
        }
        @{
            Name = 'Policy Definition Action'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''PolicyDefinitionAction'''
        }
        @{
            Name = 'Policy Definition Category'
            Expression = 'Get-AZSCSafeProperty -InputObject $state -Path ''PolicyDefinitionCategory'''
        }
        @{
            Name = 'Timestamp'
            Expression = 'if (Get-AZSCSafeProperty -InputObject $state -Path ''Timestamp'') { ([datetime](Get-AZSCSafeProperty -InputObject $state -Path ''Timestamp'')).ToString("yyyy-MM-dd HH:mm") } else { $null }'
        }
        @{
            Name = 'Management Group IDs'
            Expression = 'if (Get-AZSCSafeProperty -InputObject $state -Path ''ManagementGroupIds'') { ((Get-AZSCSafeProperty -InputObject $state -Path ''ManagementGroupIds'') -join ''; '') } else { ''None'' }'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
    )

    Export = @{
        WorksheetName = 'Policy Compliance'
        TableNamePrefix = 'PolicyCompTable_'
        Columns = @(
            'Subscription'
            'Subscription ID'
            'Resource ID'
            'Resource Type'
            'Resource Location'
            'Resource Group'
            'Policy Assignment ID'
            'Policy Assignment Name'
            'Policy Definition ID'
            'Policy Definition Name'
            'Policy Set Definition ID'
            'Compliance State'
            'Is Compliant'
            'Policy Definition Action'
            'Policy Definition Category'
            'Timestamp'
            'Management Group IDs'
            'Resource U'
        )
        TagColumns = @()
        TagColumnsBefore = $null
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText -Text ''NonCompliant'' -Range L:L -ConditionalType ContainsText -BackgroundColor Yellow'
            'New-ConditionalText -Text ''False'' -Range M:M -ConditionalType ContainsText -BackgroundColor Yellow'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Management/PolicyComplianceStates.ps1'
}