manifests/collectors/Management/DevOpsServiceConnections.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Management/DevOpsServiceConnections.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 = @(
        'devops/serviceconnections'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
            $data = $1.properties
 
            $endpointData = if ($data.PSObject.Properties.Name -contains 'data') { $data.data } else { $null }
 
            $subId = if ($endpointData -and $endpointData.PSObject.Properties.Name -contains 'subscriptionId') {
                $endpointData.subscriptionId
            } else { $null }
 
            $subName = if ($endpointData -and $endpointData.PSObject.Properties.Name -contains 'subscriptionName') {
                $endpointData.subscriptionName
            } else { $null }
 
            $authScheme = if ($data.PSObject.Properties.Name -contains 'authorization' -and $data.authorization) {
                $data.authorization.scheme
            } else { $null }
 
            $servicePrincipalId = if ($data.PSObject.Properties.Name -contains 'authorization' -and $data.authorization -and
                                      $data.authorization.PSObject.Properties.Name -contains 'parameters' -and $data.authorization.parameters -and
                                      $data.authorization.parameters.PSObject.Properties.Name -contains 'serviceprincipalid') {
                $data.authorization.parameters.serviceprincipalid
            } else { $null }
 
            $inScope = if ($subId -and $inScopeSubs.ContainsKey([string]$subId)) { 'Yes' } else { 'No' }
 
            # Workload identity federation is the credential-free scheme; anything else on
            # an ARM connection is a secret or certificate that has to be rotated.
            $credentialFree = if ($authScheme -eq 'WorkloadIdentityFederation') { 'Yes' } else { 'No' }
 
            $isShared = if ($data.PSObject.Properties.Name -contains 'isShared') { [string]$data.isShared } else { $null }
            $isReady = if ($data.PSObject.Properties.Name -contains 'isReady') { [string]$data.isReady } else { $null }
'@


    AdditionalRowLoops = @()

    TagLoop = $null

    Fields = @(
        @{
            Name = 'ID'
            Expression = '$1.id'
        }
        @{
            Name = 'Organization'
            Expression = '$1.organization'
        }
        @{
            Name = 'Project'
            Expression = '$data.projectName'
        }
        @{
            Name = 'Connection Name'
            Expression = '$1.name'
        }
        @{
            Name = 'Connection Type'
            Expression = '$data.type'
        }
        @{
            Name = 'Authorization Scheme'
            Expression = '$authScheme'
        }
        @{
            Name = 'Credential Free'
            Expression = '$credentialFree'
        }
        @{
            Name = 'Service Principal ID'
            Expression = '$servicePrincipalId'
        }
        @{
            Name = 'Target Subscription ID'
            Expression = '$subId'
        }
        @{
            Name = 'Target Subscription Name'
            Expression = '$subName'
        }
        @{
            Name = 'Subscription In Scope'
            Expression = '$inScope'
        }
        @{
            Name = 'Shared'
            Expression = '$isShared'
        }
        @{
            Name = 'Ready'
            Expression = '$isReady'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
    )

    Export = @{
        WorksheetName = 'ADO Service Connections'
        TableNamePrefix = 'ADOServiceConnectionsTable_'
        Columns = @(
            'Organization'
            'Project'
            'Connection Name'
            'Connection Type'
            'Authorization Scheme'
            'Credential Free'
            'Service Principal ID'
            'Target Subscription ID'
            'Target Subscription Name'
            'Subscription In Scope'
            'Shared'
            'Ready'
            'Resource U'
        )
        TagColumns = @()
        TagColumnsBefore = $null
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText -Text ''Yes'' -Range J:J -ConditionalType ContainsText -BackgroundColor Yellow'
            'New-ConditionalText -Text ''No'' -Range F:F -ConditionalType ContainsText -BackgroundColor Orange'
        )
    }

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