manifests/collectors/Compute/AVDSessionHosts.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Compute/AVDSessionHosts.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.desktopvirtualization/hostpools/sessionhosts'
    )

    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 host pool name from resource ID: /.../hostPools/{name}/sessionHosts/{vh}
            $idParts = $1.id -split '/'
            $shIdx = $idParts.IndexOf('sessionHosts')
            $hpIdx = $idParts.IndexOf('hostPools')
            $hostPoolName = if ($hpIdx -ge 0) { $idParts[$hpIdx + 1] } else { 'N/A' }
            $shName = if ($shIdx -ge 0) { $idParts[$shIdx + 1] } else { $1.NAME }
 
            # Arc / Azure Local detection
            $resourceId = if ($data.resourceId) { $data.resourceId } else { '' }
            $isArc = if ($resourceId -match 'Microsoft.HybridCompute/machines') { 'Yes' } else { 'No' }
            $isAzureLocal = if ($resourceId -match 'Microsoft.AzureStackHCI') { 'Yes' } else { 'No' }
 
            $lastHeartbeat = if ($data.lastHeartBeat) { ([datetime]$data.lastHeartBeat).ToString('yyyy-MM-dd HH:mm') } else { 'N/A' }
'@


    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 = 'Host Pool'
            Expression = '$hostPoolName'
        }
        @{
            Name = 'Session Host'
            Expression = '$shName'
        }
        @{
            Name = 'Status'
            Expression = 'if ($data.status) { $data.status } else { ''N/A'' }'
        }
        @{
            Name = 'Agent Version'
            Expression = 'if ($data.agentVersion) { $data.agentVersion } else { ''N/A'' }'
        }
        @{
            Name = 'OS Version'
            Expression = 'if ($data.osVersion) { $data.osVersion } else { ''N/A'' }'
        }
        @{
            Name = 'Sessions'
            Expression = 'if ($null -ne $data.sessions) { $data.sessions } else { 0 }'
        }
        @{
            Name = 'Assigned User'
            Expression = 'if ($data.assignedUser) { $data.assignedUser } else { ''Unassigned'' }'
        }
        @{
            Name = 'Allow New Session'
            Expression = 'if ($data.allowNewSession -eq $true) { ''Yes'' } else { ''No'' }'
        }
        @{
            Name = 'Update State'
            Expression = 'if ($data.updateState) { $data.updateState } else { ''N/A'' }'
        }
        @{
            Name = 'Last Heartbeat'
            Expression = '$lastHeartbeat'
        }
        @{
            Name = 'Arc Enabled'
            Expression = '$isArc'
        }
        @{
            Name = 'Azure Local'
            Expression = '$isAzureLocal'
        }
        @{
            Name = 'Resource ID'
            Expression = 'if ($resourceId) { $resourceId } else { ''N/A'' }'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'AVD Session Hosts'
        TableNamePrefix = 'AVDSessionHostsTable_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Host Pool'
            'Session Host'
            'Status'
            'Agent Version'
            'OS Version'
            'Sessions'
            'Assigned User'
            'Allow New Session'
            'Update State'
            'Last Heartbeat'
            'Arc Enabled'
            'Azure Local'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = $null
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText -ConditionalType ContainsText ''Available'' -ConditionalTextColor ([System.Drawing.Color]::FromArgb(0,176,80)) -BackgroundColor ([System.Drawing.Color]::White)'
            'New-ConditionalText -ConditionalType ContainsText ''Unavailable'' -ConditionalTextColor ([System.Drawing.Color]::White) -BackgroundColor ([System.Drawing.Color]::Red)'
            'New-ConditionalText -ConditionalType ContainsText ''Disconnected'' -ConditionalTextColor ([System.Drawing.Color]::White) -BackgroundColor ([System.Drawing.Color]::FromArgb(255,165,0))'
            'New-ConditionalText -ConditionalType ContainsText ''Yes'' -PatternType $([OfficeOpenXml.Style.ExcelFillStyle]::Solid) -ConditionalTextColor ([System.Drawing.Color]::FromArgb(0,112,192)) -BackgroundColor ([System.Drawing.Color]::White)'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Compute/AVDSessionHosts.ps1'
}