private/BootMedia/Steps/Get-OSDeployCoreBootMedia.ps1

function Get-OSDeployCoreBootMedia {
    <#
    .SYNOPSIS
        Returns a list of completed BootImage builds from the OSDeployCore boot-media directory.
 
    .DESCRIPTION
        Enumerates subdirectories under %ProgramData%\OSDeployCore\boot-media and returns
        those that contain a 'bootmedia' subfolder (indicating a completed build).
        Each result includes the build name, root path, and last-modified time.
 
    .OUTPUTS
        PSCustomObject with properties: Name, Path, ModifiedTime
 
    .NOTES
        Author: David Segura
        Company: Recast Software
        Version: 0.1.0
    #>

    [CmdletBinding()]
    param ()
    #=================================================
    $Error.Clear()
    Write-Verbose "[$(Get-Date -format G)] [$($MyInvocation.MyCommand.Name)] Start"
    #=================================================
    $BootMediaPath = Join-Path $Script:OSDeployCorePath 'boot-media'

    if (-not (Test-Path -Path $BootMediaPath)) {
        Write-Verbose "[$(Get-Date -format G)] [$($MyInvocation.MyCommand.Name)] boot-media path does not exist: $BootMediaPath"
        return
    }

    $results = Get-ChildItem -Path $BootMediaPath -Directory -ErrorAction SilentlyContinue |
        Where-Object { (Test-Path (Join-Path $_.FullName 'bootmedia')) -or (Test-Path (Join-Path $_.FullName 'bootmedia-ca2023')) } |
        Sort-Object -Property Name |
        ForEach-Object {
            [PSCustomObject]@{
                Name         = $_.Name
                Path         = $_.FullName
                ModifiedTime = $_.LastWriteTime
            }
        }

    if ($results) {
        $results
    }
    else {
        Write-Verbose "[$(Get-Date -format G)] [$($MyInvocation.MyCommand.Name)] No completed BootImage builds found in $BootMediaPath"
    }
    #=================================================
    Write-Verbose "[$(Get-Date -format G)] [$($MyInvocation.MyCommand.Name)] End"
    #=================================================
}