private/Step-BuildBootMediaIso.ps1
|
#Requires -PSEdition Core function Step-BuildBootMediaIso { <# .SYNOPSIS Creates standard and optional CA 2023 boot media ISO files .DESCRIPTION Temporarily copies ProgramData\OSDeployCore\OSDCloud\Profiles into the standard media tree when the source exists, then calls New-OSDeployCoreWindowsAdkISO to create bootmedia.iso under global BuildMedia.MediaRootPath. The temporary profile destination is removed after ISO creation. When global BuildMedia.MediaPathEX is set, the function repeats the profile copy and cleanup for that media tree and creates bootmedia_ca2023.iso. Both ISOs use global BuildMedia.MediaIsoLabel and BuildMedia.AdkRootPath. .EXAMPLE PS> Step-BuildBootMediaIso Creates the configured standard ISO and the extended ISO when MediaPathEX is set. .INPUTS None. This function does not accept pipeline input. .OUTPUTS None. Output from New-OSDeployCoreWindowsAdkISO is suppressed. .NOTES Author: David Segura Company: Recast Software Version: 0.1.0 Date: 2026-08-28 Requires global BuildMedia with AdkRootPath, MediaIsoLabel, MediaPath, MediaPathEX, and MediaRootPath properties and New-OSDeployCoreWindowsAdkISO. The delegated command requires Windows ADK ISO tooling. Temporarily replaces and then removes OSDCloud\Profiles in each media tree. #> [CmdletBinding()] param () $AdkRootPath = $global:BuildMedia.AdkRootPath $MediaIsoLabel = $global:BuildMedia.MediaIsoLabel $MediaPath = $global:BuildMedia.MediaPath $MediaPathEX = $global:BuildMedia.MediaPathEX $MediaRootPath = $global:BuildMedia.MediaRootPath Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [INFO] Creating bootable ISO in $MediaRootPath" # Copy Profiles from $env:ProgramData\OSDeployCore\OSDCloud\Profiles to $MediaPath\OSDCloud\Profiles $SourceProfilesPath = "$env:ProgramData\OSDeployCore\OSDCloud\Profiles" $DestinationProfilesPath = Join-Path -Path $MediaPath -ChildPath "OSDCloud\Profiles" if (Test-Path -Path $SourceProfilesPath) { Copy-Item -Path $SourceProfilesPath -Destination $DestinationProfilesPath -Recurse -Force } $Params = @{ MediaPath = $MediaPath IsoFileName = 'bootmedia.iso' IsoLabel = $MediaIsoLabel WindowsAdkRoot = $AdkRootPath IsoDirectory = $MediaRootPath } New-OSDeployCoreWindowsAdkISO @Params | Out-Null # Remove copied profiles from $MediaPath\OSDCloud\Profiles if (Test-Path -Path $DestinationProfilesPath) { Remove-Item -Path $DestinationProfilesPath -Recurse -Force } if ($MediaPathEX) { # Copy Profiles from $env:ProgramData\OSDeployCore\OSDCloud\Profiles to $MediaPathEX\OSDCloud\Profiles if ($MediaPathEX) { $DestinationProfilesPathEX = Join-Path -Path $MediaPathEX -ChildPath "OSDCloud\Profiles" if (Test-Path -Path $SourceProfilesPath) { Copy-Item -Path $SourceProfilesPath -Destination $DestinationProfilesPathEX -Recurse -Force } } $Params = @{ MediaPath = $MediaPathEX IsoFileName = 'bootmedia_ca2023.iso' IsoLabel = $MediaIsoLabel WindowsAdkRoot = $AdkRootPath IsoDirectory = $MediaRootPath } New-OSDeployCoreWindowsAdkISO @Params | Out-Null # Remove copied profiles from $MediaPathEX\OSDCloud\Profiles if (Test-Path -Path $DestinationProfilesPathEX) { Remove-Item -Path $DestinationProfilesPathEX -Recurse -Force } } } |