manifests/collectors/Management/MaintenanceConfigurations.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Management/MaintenanceConfigurations.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.maintenance/maintenanceconfigurations'
    )

    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 maintenance window
                $maintenanceWindow = $data.maintenanceWindow
 
                # Parse maintenance scope
                $scope = $data.maintenanceScope
                $scopeFriendly = switch ($scope) {
                    'Host' { 'Dedicated Hosts' }
                    'OSImage' { 'OS Image Updates' }
                    'Extension' { 'VM Extensions' }
                    'InGuestPatch' { 'In-Guest Patching' }
                    'SQLDB' { 'SQL Database' }
                    'SQLManagedInstance' { 'SQL Managed Instance' }
                    default { $scope }
                }
 
                # Parse recurrence pattern
                $recurEvery = if ($maintenanceWindow.recurEvery) { $maintenanceWindow.recurEvery } else { 'Not specified' }
 
                # Parse OS filter
                $osFilter = 'All'
                if ($data.installPatches -and $data.installPatches.windowsParameters) {
                    $osFilter = 'Windows'
                } elseif ($data.installPatches -and $data.installPatches.linuxParameters) {
                    $osFilter = 'Linux'
                }
 
                # Get classification filters
                $classifications = @()
                if ($data.installPatches.windowsParameters.classificationsToInclude) {
                    $classifications = $data.installPatches.windowsParameters.classificationsToInclude
                } elseif ($data.installPatches.linuxParameters.classificationsToInclude) {
                    $classifications = $data.installPatches.linuxParameters.classificationsToInclude
                }
                $classificationsStr = if ($classifications) { ($classifications -join ', ') } else { 'All' }
 
                # Reboot setting
                $rebootSetting = 'IfRequired'
                if ($data.installPatches.rebootSetting) {
                    $rebootSetting = $data.installPatches.rebootSetting
                } elseif ($data.installPatches.windowsParameters.rebootSetting) {
                    $rebootSetting = $data.installPatches.windowsParameters.rebootSetting
                } elseif ($data.installPatches.linuxParameters.rebootSetting) {
                    $rebootSetting = $data.installPatches.linuxParameters.rebootSetting
                }
 
                # Pre/Post tasks
                $preTasks = if ($data.tasks -and $data.tasks.preMaintenanceTasks) {
                    ($data.tasks.preMaintenanceTasks | ForEach-Object { $_.source } | Where-Object { $_ }) -join '; '
                } else { 'None' }
 
                $postTasks = if ($data.tasks -and $data.tasks.postMaintenanceTasks) {
                    ($data.tasks.postMaintenanceTasks | ForEach-Object { $_.source } | Where-Object { $_ }) -join '; '
                } else { 'None' }
 
                # KB numbers
                $kbInclude = if ($data.installPatches.windowsParameters.kbNumbersToInclude) {
                    ($data.installPatches.windowsParameters.kbNumbersToInclude -join ', ')
                } else { 'None' }
                $kbExclude = if ($data.installPatches.windowsParameters.kbNumbersToExclude) {
                    ($data.installPatches.windowsParameters.kbNumbersToExclude -join ', ')
                } else { 'None' }
 
                # Package names
                $pkgInclude = if ($data.installPatches.linuxParameters.packageNameMasksToInclude) {
                    ($data.installPatches.linuxParameters.packageNameMasksToInclude -join ', ')
                } else { 'None' }
                $pkgExclude = if ($data.installPatches.linuxParameters.packageNameMasksToExclude) {
                    ($data.installPatches.linuxParameters.packageNameMasksToExclude -join ', ')
                } else { 'None' }
'@


    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 = 'Configuration Name'
            Expression = '$1.NAME'
        }
        @{
            Name = 'Location'
            Expression = '$1.LOCATION'
        }
        @{
            Name = 'Scope'
            Expression = '$scopeFriendly'
        }
        @{
            Name = 'Recurrence Pattern'
            Expression = '$recurEvery'
        }
        @{
            Name = 'Start Time (UTC)'
            Expression = 'if ($maintenanceWindow.startDateTime) { $maintenanceWindow.startDateTime } else { ''Not scheduled'' }'
        }
        @{
            Name = 'Duration (hours)'
            Expression = 'if ($maintenanceWindow.duration) { $maintenanceWindow.duration } else { ''Not specified'' }'
        }
        @{
            Name = 'Time Zone'
            Expression = 'if ($maintenanceWindow.timeZone) { $maintenanceWindow.timeZone } else { ''UTC'' }'
        }
        @{
            Name = 'OS Filter'
            Expression = '$osFilter'
        }
        @{
            Name = 'Patch Classifications'
            Expression = '$classificationsStr'
        }
        @{
            Name = 'Reboot Setting'
            Expression = '$rebootSetting'
        }
        @{
            Name = 'KB Numbers (Include)'
            Expression = '$kbInclude'
        }
        @{
            Name = 'KB Numbers (Exclude)'
            Expression = '$kbExclude'
        }
        @{
            Name = 'Package Names (Include)'
            Expression = '$pkgInclude'
        }
        @{
            Name = 'Package Names (Exclude)'
            Expression = '$pkgExclude'
        }
        @{
            Name = 'Pre-Maintenance Tasks'
            Expression = '$preTasks'
        }
        @{
            Name = 'Post-Maintenance Tasks'
            Expression = '$postTasks'
        }
        @{
            Name = 'Visibility'
            Expression = 'if ($data.visibility) { $data.visibility } else { ''Custom'' }'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'Maintenance Configs'
        TableNamePrefix = 'MaintConfigTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Configuration Name'
            'Location'
            'Scope'
            'Recurrence Pattern'
            'Start Time (UTC)'
            'Duration (hours)'
            'Time Zone'
            'OS Filter'
            'Patch Classifications'
            'Reboot Setting'
            'KB Numbers (Include)'
            'KB Numbers (Exclude)'
            'Package Names (Include)'
            'Package Names (Exclude)'
            'Pre-Maintenance Tasks'
            'Post-Maintenance Tasks'
            'Visibility'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @()
    }

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