manifests/collectors/Web/APPServicePlan.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Web/APPServicePlan.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.web/serverfarms'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    SetupPreamble = @'
$APPSvcPlan = $Resources | Where-Object {$_.TYPE -eq 'microsoft.web/serverfarms'}
        $APPAutoScale = $Resources | Where-Object {$_.TYPE -eq "microsoft.insights/autoscalesettings" -and $_.Properties.enabled -eq 'true'}
'@


    SetupVariables = @(
        'APPSvcPlan'
        'APPAutoScale'
    )

    Preamble = @'
$ResUCount = 1
                Remove-Variable AutoScale -ErrorAction SilentlyContinue
                $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId }
                $data = $1.PROPERTIES
                $sku = $1.SKU
                $Orphaned = if([string]::IsNullOrEmpty($data.numberOfSites) -or $data.numberOfSites -eq 0){$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
                    }
                $AutoScale = ($APPAutoScale | Where-Object {$_.Properties.targetResourceUri -eq $1.id})
                if([string]::IsNullOrEmpty($AutoScale)){$AutoSc = $false}else{$AutoSc = $true}
                $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'}
'@


    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 = 'Pricing Tier'
            Expression = '($sku.tier+''(''+$sku.name+'': ''+$data.currentNumberOfWorkers+'')'')'
        }
        @{
            Name = 'Compute Mode'
            Expression = '$data.computeMode'
        }
        @{
            Name = 'Intances Size'
            Expression = '$data.currentWorkerSize'
        }
        @{
            Name = 'Current Instances'
            Expression = '$data.currentNumberOfWorkers'
        }
        @{
            Name = 'Autoscale Enabled'
            Expression = '$AutoSc'
        }
        @{
            Name = 'Max Instances'
            Expression = '$data.maximumNumberOfWorkers'
        }
        @{
            Name = 'App Plan OS'
            Expression = 'if ($data.reserved -eq ''true'') { ''Linux'' }else { ''Windows'' }'
        }
        @{
            Name = 'Apps Type'
            Expression = '$data.kind'
        }
        @{
            Name = 'Apps'
            Expression = '$data.numberOfSites'
        }
        @{
            Name = 'Zone Redundant'
            Expression = '$data.zoneRedundant'
        }
        @{
            Name = 'Orphaned'
            Expression = '$Orphaned'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'App Service Plan'
        TableNamePrefix = 'AppSvcPlanTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Name'
            'Location'
            'Retiring Feature'
            'Retiring Date'
            'Pricing Tier'
            'Orphaned'
            'Compute Mode'
            'Intances Size'
            'Current Instances'
            'Autoscale Enabled'
            'Max Instances'
            'App Plan OS'
            'Apps Type'
            'Apps'
            'Zone Redundant'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText FALSE -Range K:K'
            'New-ConditionalText FALSE -Range O:O'
            'New-ConditionalText Free -Range G:G'
            'New-ConditionalText Basic -Range G:G'
            'New-ConditionalText -Range E2:E100 -ConditionalType ContainsText'
            'New-ConditionalText TRUE -Range H:H'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Web/APPServicePlan.ps1'
}