manifests/collectors/Networking/Connections.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Networking/Connections.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.network/connections'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
                $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId }
                $data = $1.PROPERTIES
                $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
                    }
                $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'}
 
                # IPsec Policy (first policy if multiple)
                $ipsecPolicy = if ($data.ipsecPolicies -and @($data.ipsecPolicies).count -gt 0) { @($data.ipsecPolicies)[0] } else { $null }
                $IPsecEncryption = if ($ipsecPolicy) { $ipsecPolicy.ipsecEncryption } else { $null }
                $IPsecIntegrity = if ($ipsecPolicy) { $ipsecPolicy.ipsecIntegrity } else { $null }
                $IKEEncryption = if ($ipsecPolicy) { $ipsecPolicy.ikeEncryption } else { $null }
                $IKEIntegrity = if ($ipsecPolicy) { $ipsecPolicy.ikeIntegrity } else { $null }
                $DHGroup = if ($ipsecPolicy) { $ipsecPolicy.dhGroup } else { $null }
                $PFSGroup = if ($ipsecPolicy) { $ipsecPolicy.pfsGroup } else { $null }
                $SALifetime = if ($ipsecPolicy) { $ipsecPolicy.saLifeTimeSeconds } else { $null }
                $SADataSize = if ($ipsecPolicy) { $ipsecPolicy.saDataSizeKilobytes } else { $null }
 
                # Traffic selectors
                $TrafficSelectors = if ($data.trafficSelectorPolicies -and @($data.trafficSelectorPolicies).count -gt 0) {
                    ($data.trafficSelectorPolicies | ForEach-Object {
                        'Local:' + ($_.localAddressRanges -join ',') + ' Remote:' + ($_.remoteAddressRanges -join ',')
                    }) -join '; '
                } else { $null }
 
                # Shared Key - boolean only, NEVER log the actual key
                $SharedKeySet = if ($data.sharedKey) { 'Yes' } else { 'No' }
'@


    AdditionalRowLoops = @()

    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 = 'Location'
            Expression = '$1.LOCATION'
        }
        @{
            Name = 'Retiring Feature'
            Expression = '$RetiringFeature'
        }
        @{
            Name = 'Retiring Date'
            Expression = '$RetiringDate'
        }
        @{
            Name = 'Type'
            Expression = '$data.connectionType'
        }
        @{
            Name = 'Status'
            Expression = '$data.connectionStatus'
        }
        @{
            Name = 'Connection Protocol'
            Expression = '$data.connectionProtocol'
        }
        @{
            Name = 'Routing Weight'
            Expression = '$data.routingWeight'
        }
        @{
            Name = 'connectionMode'
            Expression = '$data.connectionMode'
        }
        @{
            Name = 'IPsec Encryption'
            Expression = '$IPsecEncryption'
        }
        @{
            Name = 'IPsec Integrity'
            Expression = '$IPsecIntegrity'
        }
        @{
            Name = 'IKE Encryption'
            Expression = '$IKEEncryption'
        }
        @{
            Name = 'IKE Integrity'
            Expression = '$IKEIntegrity'
        }
        @{
            Name = 'DH Group'
            Expression = '$DHGroup'
        }
        @{
            Name = 'PFS Group'
            Expression = '$PFSGroup'
        }
        @{
            Name = 'SA Lifetime (sec)'
            Expression = '$SALifetime'
        }
        @{
            Name = 'SA Data Size (KB)'
            Expression = '$SADataSize'
        }
        @{
            Name = 'Use Policy-Based TS'
            Expression = '$data.usePolicyBasedTrafficSelectors'
        }
        @{
            Name = 'Traffic Selectors'
            Expression = '$TrafficSelectors'
        }
        @{
            Name = 'DPD Timeout (sec)'
            Expression = '$data.dpdTimeoutSeconds'
        }
        @{
            Name = 'Ingress Bytes'
            Expression = '$data.ingressBytesTransferred'
        }
        @{
            Name = 'Egress Bytes'
            Expression = '$data.egressBytesTransferred'
        }
        @{
            Name = 'Shared Key Set'
            Expression = '$SharedKeySet'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'Connections'
        TableNamePrefix = 'Connections_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Name'
            'Location'
            'Retiring Feature'
            'Retiring Date'
            'Type'
            'Status'
            'Connection Protocol'
            'Routing Weight'
            'connectionMode'
            'IPsec Encryption'
            'IPsec Integrity'
            'IKE Encryption'
            'IKE Integrity'
            'DH Group'
            'PFS Group'
            'SA Lifetime (sec)'
            'SA Data Size (KB)'
            'Use Policy-Based TS'
            'Traffic Selectors'
            'DPD Timeout (sec)'
            'Ingress Bytes'
            'Egress Bytes'
            'Shared Key Set'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText -Range E2:E100 -ConditionalType ContainsText'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Networking/Connections.ps1'
}