private/Get-OSDeployCoreBootMedia.ps1
|
function Get-OSDeployCoreBootMedia { <# .SYNOPSIS Gets completed OSDeployCore boot media builds .DESCRIPTION Enumerates directories beneath the script-scoped OSDeployCore boot path and returns builds that contain either a bootmedia or bootmedia_ca2023 child directory. Results are ordered by ModifiedTime descending. No objects are returned when the boot path does not exist or contains no completed builds. .EXAMPLE PS> Get-OSDeployCoreBootMedia Returns completed boot media builds from the configured OSDeployCore boot path. .INPUTS None. This function does not accept pipeline input. .OUTPUTS System.Management.Automation.PSCustomObject. Returns zero or more objects with ModifiedTime, Name, and Path properties. .NOTES Author: David Segura Company: Recast Software Version: 0.1.0 Date: 2026-08-28 Dependencies: None #> [CmdletBinding()] param () #================================================= $Error.Clear() Write-Verbose "[$($MyInvocation.MyCommand.Name)] Start" #================================================= $OSDeployCoreBootPath = Join-Path $Script:OSDeployCorePath 'boot' if (-not (Test-Path -Path $OSDeployCoreBootPath)) { Write-Verbose "[$($MyInvocation.MyCommand.Name)] boot path does not exist: $OSDeployCoreBootPath" return } $results = Get-ChildItem -Path $OSDeployCoreBootPath -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]@{ ModifiedTime = $_.LastWriteTime Name = $_.Name Path = $_.FullName } } if ($results) { $results | Sort-Object -Property ModifiedTime -Descending } else { Write-Verbose "[$($MyInvocation.MyCommand.Name)] No completed BootMedia found in $OSDeployCoreBootPath" } #================================================= Write-Verbose "[$($MyInvocation.MyCommand.Name)] End" #================================================= } |