Public/Get-SummitSession.ps1

function Get-SummitSession {
    <#
    .SYNOPSIS
        Gets detailed information for a summit session including its full description.
 
    .DESCRIPTION
        Returns session details (description, speaker company, tags) from bundled data.
        No network calls required. Accepts pipeline input from Get-SummitSchedule or
        a title search string.
 
    .PARAMETER Title
        Search for sessions by title (wildcard match). If multiple sessions match,
        details are returned for all of them.
 
    .PARAMETER Year
        The summit year to query when searching by title. Defaults to the current year.
        Ignored when using pipeline input (year is inferred from the piped session).
 
    .PARAMETER InputObject
        A session object from Get-SummitSchedule. Accepts pipeline input.
 
    .EXAMPLE
        Get-SummitSession -Title "DevOps in the Age of AI"
 
    .EXAMPLE
        Get-SummitSchedule -Category Keynote | Get-SummitSession
 
    .EXAMPLE
        Get-SummitSchedule -Speaker "Justin Grote" | Get-SummitSession
    #>

    [CmdletBinding(DefaultParameterSetName = 'BySearch')]
    [OutputType('SummitSchedule.SessionDetail')]
    param(
        [Parameter(Mandatory, ParameterSetName = 'BySearch', Position = 0)]
        [string]$Title,

        [Parameter(ParameterSetName = 'BySearch')]
        [int]$Year = (Get-Date).Year,

        [Parameter(Mandatory, ParameterSetName = 'ByPipeline', ValueFromPipeline)]
        [PSTypeName('SummitSchedule.Session')]
        $InputObject
    )

    begin {
        $detailCache = @{}
    }

    process {
        if ($PSCmdlet.ParameterSetName -eq 'BySearch') {
            $searchYear = $Year
        }
        else {
            $searchYear = $InputObject.Year
        }

        # Load detail data if not cached
        if (-not $detailCache.ContainsKey($searchYear)) {
            $dataFile = Join-Path $script:DataPath "$searchYear.json"
            if (-not (Test-Path $dataFile)) {
                Write-Error "No schedule data found for $searchYear."
                return
            }
            $detailCache[$searchYear] = Get-Content -Path $dataFile -Raw | ConvertFrom-Json
        }

        $allData = $detailCache[$searchYear]

        if ($PSCmdlet.ParameterSetName -eq 'BySearch') {
            $found = @($allData | Where-Object { $_.Title -like "*$Title*" })
            if ($found.Count -eq 0) {
                Write-Error "No sessions found matching '$Title'"
                return
            }
        }
        else {
            $found = @($allData | Where-Object { $_.EventId -eq $InputObject.EventId })
            if ($found.Count -eq 0) {
                $found = @($allData | Where-Object { $_.Title -eq $InputObject.Title })
            }
        }

        foreach ($r in $found) {
            [PSCustomObject]@{
                PSTypeName     = 'SummitSchedule.SessionDetail'
                Title          = $r.Title
                Day            = $r.Day
                Date           = $r.Date
                Time           = $r.Time
                Speaker        = $r.Speaker
                SpeakerCompany = $r.SpeakerCompany
                Room           = $r.Room
                Category       = $r.Category
                Tags           = $r.Tags
                Description    = $r.Description
                EventId        = $r.EventId
                Url            = $r.Url
                Year           = [int]$r.Year
            }
        }
    }
}