manifests/collectors/Monitor/ActionGroups.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Monitor/ActionGroups.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.insights/actiongroups'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
                $sub1 = $SUB | Where-Object { $_.Id -eq $1.subscriptionId }
                $data = $1.PROPERTIES
                $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'}
 
                # Parse email receivers
                $emailReceivers = @()
                if ($data.emailReceivers) {
                    foreach ($email in $data.emailReceivers) {
                        $emailReceivers += "$($email.name): $($email.emailAddress)"
                    }
                }
                $emailStr = if ($emailReceivers.Count -gt 0) { $emailReceivers -join '; ' } else { 'None' }
 
                # Parse SMS receivers
                $smsReceivers = @()
                if ($data.smsReceivers) {
                    foreach ($sms in $data.smsReceivers) {
                        $smsReceivers += "$($sms.name): $($sms.countryCode)-$($sms.phoneNumber)"
                    }
                }
                $smsStr = if ($smsReceivers.Count -gt 0) { $smsReceivers -join '; ' } else { 'None' }
 
                # Parse webhook receivers
                $webhookReceivers = @()
                if ($data.webhookReceivers) {
                    foreach ($webhook in $data.webhookReceivers) {
                        $webhookReceivers += "$($webhook.name): $($webhook.serviceUri)"
                    }
                }
                $webhookStr = if ($webhookReceivers.Count -gt 0) { $webhookReceivers -join '; ' } else { 'None' }
 
                # Parse Azure app push receivers
                $appPushReceivers = @()
                if ($data.azureAppPushReceivers) {
                    foreach ($push in $data.azureAppPushReceivers) {
                        $appPushReceivers += "$($push.name): $($push.emailAddress)"
                    }
                }
                $appPushStr = if ($appPushReceivers.Count -gt 0) { $appPushReceivers -join '; ' } else { 'None' }
 
                # Parse automation runbook receivers
                $runbookReceivers = @()
                if ($data.automationRunbookReceivers) {
                    foreach ($runbook in $data.automationRunbookReceivers) {
                        $runbookReceivers += "$($runbook.name): $($runbook.runbookName)"
                    }
                }
                $runbookStr = if ($runbookReceivers.Count -gt 0) { $runbookReceivers -join '; ' } else { 'None' }
 
                # Parse Azure Function receivers
                $functionReceivers = @()
                if ($data.azureFunctionReceivers) {
                    foreach ($func in $data.azureFunctionReceivers) {
                        $functionReceivers += "$($func.name): $($func.functionName)"
                    }
                }
                $functionStr = if ($functionReceivers.Count -gt 0) { $functionReceivers -join '; ' } else { 'None' }
 
                # Parse Logic App receivers
                $logicAppReceivers = @()
                if ($data.logicAppReceivers) {
                    foreach ($logic in $data.logicAppReceivers) {
                        $logicAppReceivers += "$($logic.name): $($logic.resourceId -split '/')[-1]"
                    }
                }
                $logicAppStr = if ($logicAppReceivers.Count -gt 0) { $logicAppReceivers -join '; ' } else { 'None' }
 
                # Get enabled status
                $enabled = if ($data.enabled -eq $true) { 'Enabled' } else { 'Disabled' }
'@


    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 = 'Action Group Name'
            Expression = '$1.NAME'
        }
        @{
            Name = 'Short Name'
            Expression = 'if ($data.groupShortName) { $data.groupShortName } else { ''N/A'' }'
        }
        @{
            Name = 'Location'
            Expression = '$1.LOCATION'
        }
        @{
            Name = 'Status'
            Expression = '$enabled'
        }
        @{
            Name = 'Email Receivers'
            Expression = '$emailStr'
        }
        @{
            Name = 'SMS Receivers'
            Expression = '$smsStr'
        }
        @{
            Name = 'Webhook Receivers'
            Expression = '$webhookStr'
        }
        @{
            Name = 'Azure App Push'
            Expression = '$appPushStr'
        }
        @{
            Name = 'Automation Runbooks'
            Expression = '$runbookStr'
        }
        @{
            Name = 'Azure Functions'
            Expression = '$functionStr'
        }
        @{
            Name = 'Logic Apps'
            Expression = '$logicAppStr'
        }
        @{
            Name = 'Total Receivers'
            Expression = '($emailReceivers.Count + $smsReceivers.Count + $webhookReceivers.Count + $appPushReceivers.Count + $runbookReceivers.Count + $functionReceivers.Count + $logicAppReceivers.Count)'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'Action Groups'
        TableNamePrefix = 'ActionGroupsTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Action Group Name'
            'Short Name'
            'Location'
            'Status'
            'Email Receivers'
            'SMS Receivers'
            'Webhook Receivers'
            'Azure App Push'
            'Automation Runbooks'
            'Azure Functions'
            'Logic Apps'
            'Total Receivers'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @()
    }

    SourceCollector = 'Modules/Public/InventoryModules/Monitor/ActionGroups.ps1'
}