manifests/collectors/AI/ContentModerator.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/AI/ContentModerator.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 = @(
        'microsoft.cognitiveservices/accounts'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = '$_.Kind -eq ''ContentModerator'''

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
                $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId }
                $data = $1.PROPERTIES
                $timecreated = $data.datecreated
                $timecreated = [datetime]$timecreated
                $timecreated = $timecreated.ToString("yyyy-MM-dd HH:mm")
                $Retired = $Retirements | Where-Object { $_.id -eq $1.id }
                if ($Retired)
                    {
                        $RetiredFeature = foreach ($Retire in $Retired)
                            {
                                $RetiredServiceID = $Unsupported | Where-Object {$_.Id -eq $Retired.ServiceID}
                                $tmp0 = [pscustomobject]@{
                                        'RetiredFeature' = $RetiredServiceID.RetiringFeature
                                        'RetiredDate' = $RetiredServiceID.RetirementDate
                                    }
                                $tmp0
                            }
                        $RetiringFeature = if (@($RetiredFeature.RetiredFeature).count -gt 1) { $RetiredFeature.RetiredFeature | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredFeature}
                        $RetiringFeature = [string]$RetiringFeature
                        $RetiringFeature = if ($RetiringFeature -like '* ,*') { $RetiringFeature -replace ".$" }else { $RetiringFeature }
 
                        $RetiringDate = if (@($RetiredFeature.RetiredDate).count -gt 1) { $RetiredFeature.RetiredDate | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredDate}
                        $RetiringDate = [string]$RetiringDate
                        $RetiringDate = if ($RetiringDate -like '* ,*') { $RetiringDate -replace ".$" }else { $RetiringDate }
                    }
                else
                    {
                        $RetiringFeature = $null
                        $RetiringDate = $null
                    }
                $pvt = if(![string]::IsNullOrEmpty($data.privateendpointconnections)){$data.privateendpointconnections}else{'0'}
                $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'}
'@


    AdditionalRowLoops = @(
        @{
            Variable = 'pv'
            # AB#6845 decision ($pv): NO EmitNullWhenEmpty, deliberately. $pvt is assigned through
            # a sentinel in the row preamble -- if the account carries no
            # privateEndpointConnections it becomes '0' rather than an empty collection -- so this
            # loop always runs at least once and a Content Moderator account keeps its row.
            #
            # This is not a lucky accident worth leaving unstated: a private endpoint is opt-in,
            # so HAVING NONE IS THE DEFAULT. The sentinel is the only reason this worksheet is not
            # empty for a typical estate, and deleting it reopens AB#6845 here.
            #
            # EmitNullWhenEmpty would be dead configuration -- it fires on an EMPTY source, and
            # the sentinel guarantees this source is never empty. Adding it would also change the
            # shipped column value from '0' to blank for every account that has no connections.
            Source = '$pvt'
            Preamble = '$priv = (Get-AZSCIdSegment -Id $pv -Index 8)'
        }
    )

    TagLoop = @{
        Variable = 'Tag'
        Source = '$Tags'
        Preamble = ''
    }

    Fields = @(
        @{
            Name = 'ID'
            Expression = '$1.id'
        }
        @{
            Name = 'Subscription'
            Expression = '$sub1.Name'
        }
        @{
            Name = 'Resource Group'
            Expression = '$1.RESOURCEGROUP'
        }
        @{
            Name = 'Name'
            Expression = '$1.NAME'
        }
        @{
            Name = 'SKU'
            Expression = '$1.sku.name'
        }
        @{
            Name = 'Retiring Feature'
            Expression = '$RetiringFeature'
        }
        @{
            Name = 'Retiring Date'
            Expression = '$RetiringDate'
        }
        @{
            Name = 'Public Network Access'
            Expression = '$data.publicnetworkaccess'
        }
        @{
            Name = 'Creation Time'
            Expression = '$timecreated'
        }
        @{
            Name = 'Is Migrated'
            Expression = '$data.ismigrated'
        }
        @{
            Name = 'Custom Domain Name'
            Expression = '$data.customsubdomainname'
        }
        @{
            Name = 'Endpoint'
            Expression = '$data.endpoint'
        }
        @{
            Name = 'Network Default Action'
            Expression = '$data.networkacls.defaultaction'
        }
        @{
            Name = 'IP Rules'
            Expression = '@($data.networkacls.iprules).count'
        }
        @{
            Name = 'Virtual Network Rules'
            Expression = '@($data.networkacls.virtualnetworkrules).count'
        }
        @{
            Name = 'Private Endpoint'
            Expression = '$priv'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'Content Moderator'
        TableNamePrefix = 'ContentModTb_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Name'
            'SKU'
            'Retiring Feature'
            'Retiring Date'
            'Public Network Access'
            'Creation Time'
            'Is Migrated'
            'Custom Domain Name'
            'Endpoint'
            'Network Default Action'
            'IP Rules'
            'Virtual Network Rules'
            'Private Endpoint'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText F0 -Range D:D'
            'New-ConditionalText -Range E2:E100 -ConditionalType ContainsText'
            'New-ConditionalText enabled -Range G:G'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/AI/ContentModerator.ps1'
}