private/Get-OSDeployBootUSBLabel.ps1
|
function Get-OSDeployBootUSBLabel { <# .SYNOPSIS Gets the architecture-specific USB boot label for a completed build .DESCRIPTION Reads Architecture from properties.json in the selected build directory and returns BOOT-AMD64 or BOOT-ARM64. Missing, unreadable, malformed, or unsupported metadata produces a terminating error. No architecture is inferred from the host or build name. .PARAMETER BuildPath Specifies the completed build directory containing properties.json. .EXAMPLE PS> Get-OSDeployBootUSBLabel -BuildPath 'C:\ProgramData\OSDeployCore\boot\MyBuild' Returns the USB boot label for the architecture recorded in the build metadata. .INPUTS None. This function does not accept pipeline input. .OUTPUTS System.String. Returns BOOT-AMD64 or BOOT-ARM64. .NOTES Author: David Segura Company: Recast Software Version: 1.0.0 Date: 2026-10-02 Requires a completed build with properties.json containing amd64 or arm64 Architecture. #> [CmdletBinding()] [OutputType([System.String])] param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$BuildPath ) Write-Verbose "[$($MyInvocation.MyCommand.Name)] Start" $propertiesPath = Join-Path $BuildPath 'properties.json' try { $properties = Get-Content -LiteralPath $propertiesPath -Raw -ErrorAction Stop | ConvertFrom-Json -ErrorAction Stop } catch { throw "[$($MyInvocation.MyCommand.Name)] Unable to read build metadata '$propertiesPath'. $($_.Exception.Message)" } if ($properties.Architecture -isnot [string] -or $properties.Architecture -notin @('amd64', 'arm64')) { throw "[$($MyInvocation.MyCommand.Name)] Build metadata '$propertiesPath' must contain Architecture 'amd64' or 'arm64'." } $label = "BOOT-$($properties.Architecture.ToUpperInvariant())" Write-Verbose "[$($MyInvocation.MyCommand.Name)] End" return $label } |