manifests/collectors/Networking/LoadBalancer.psd1

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

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
                $sub1 = $SUB | Where-Object { $_.Id -eq $1.subscriptionId }
                $data = $1.PROPERTIES
                $Orphaned = if([string]::IsNullOrEmpty($data.backendAddressPools.id)){$true}else{$false}
                $Retired = Foreach ($Retirement in $Retirements)
                    {
                        if ($Retirement.id -eq $1.id) { $Retirement }
                    }
                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'}
                $FrontEnds = foreach ($2 in $data.frontendIPConfigurations)
                    {
                        if (![string]::IsNullOrEmpty($2.properties.subnet.id))
                            {
                                $tmps = [pscustomobject]@{
                                    Name = $2.name
                                    Fronttarget = $2.properties.subnet.id.split('/')[8]
                                    FrontType = 'VNET'
                                    frontsub = $2.properties.subnet.id.split('/')[10]
                                }
                                $tmps
                            }
                        elseif (![string]::IsNullOrEmpty($2.properties.publicIPAddress.id))
                            {
                                $tmps = [pscustomobject]@{
                                    Name = $2.name
                                    Fronttarget = $2.properties.publicIPAddress.id.split('/')[8]
                                    FrontType = 'Public IP'
                                    frontsub = $null
                                }
                                $tmps
                            }
                    }
                $Backends = @($data.backendAddressPools).count
 
                $BackendState = if(![string]::IsNullOrEmpty($data.backendAddressPools.properties.loadBalancerBackendAddresses)){'In Use'}else{'Not In Use'}
 
                $Probes = @($data.probes).count
 
                $FrontEnds = if(![string]::IsNullOrEmpty($FrontEnds)){$FrontEnds}else{'0'}
'@


    AdditionalRowLoops = @(
        @{
            Variable = 'FrontEnd'
            Source = '$FrontEnds'
            Preamble = ''
        }
    )

    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 = 'SKU'
            Expression = '$1.sku.name'
        }
        @{
            Name = 'Retiring Feature'
            Expression = '$RetiringFeature'
        }
        @{
            Name = 'Retiring Date'
            Expression = '$RetiringDate'
        }
        @{
            Name = 'Orphaned'
            Expression = '$Orphaned'
        }
        @{
            Name = 'Usage'
            Expression = '$BackendState'
        }
        @{
            Name = 'Frontend Name'
            Expression = '$FrontEnd.Name'
        }
        @{
            Name = 'Frontend Target'
            Expression = '$FrontEnd.Fronttarget'
        }
        @{
            Name = 'Frontend Type'
            Expression = '$FrontEnd.FrontType'
        }
        @{
            Name = 'Frontend Subnet'
            Expression = '$FrontEnd.frontsub'
        }
        @{
            Name = 'Backend Count'
            Expression = '$BackEnds'
        }
        @{
            Name = 'Probe Count'
            Expression = '$Probes'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'Load Balancers'
        TableNamePrefix = 'LBTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Name'
            'Location'
            'SKU'
            'Retiring Feature'
            'Retiring Date'
            'Orphaned'
            'Usage'
            'Frontend Name'
            'Frontend Target'
            'Frontend Type'
            'Frontend Subnet'
            'Backend Count'
            'Probe Count'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText -Range F2:F100 -ConditionalType ContainsText'
            'New-ConditionalText Basic -Range E:E'
            'New-ConditionalText TRUE -Range H:H'
            'New-ConditionalText ''Not In Use'' -Range I:I'
        )
    }

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