public/Update-OSDeployBootISO.ps1
|
#Requires -PSEdition Core function Update-OSDeployBootISO { <# .SYNOPSIS Rebuilds the bootable ISO files for a selected OSDeployCore BootImage build. .DESCRIPTION Regenerates the ISO files (bootmedia.iso and optionally bootmedia_ca2023.iso) for a selected completed BootImage from %ProgramData%\OSDeployCore\boot. The existing bootmedia directory content is used as-is; no DISM mount or WIM modification is performed. The function: - Prompts for selection of a completed BootImage build - Verifies the Windows ADK is installed - Uses the installed ADK's oscdimg.exe to rebuild the ISO(s) - Places ISOs in the BootImage's root directory .EXAMPLE Update-OSDeployBootISO Prompts for a BootImage build selection and rebuilds its ISO files using the installed ADK. .INPUTS None. This function does not accept pipeline input. .OUTPUTS None. .NOTES Author: David Segura Company: Recast Software Version: 26.7.30 Date: April 2026 Prerequisites: - PowerShell 7.4 or higher (MSI install) - Windows 11 25H2 or higher (build 26200) - Run as Administrator - Windows ADK installed - At least one completed BootImage build in %ProgramData%\OSDeployCore\boot Dependencies: Module Functions: Get-OSDeployCoreWindowsAdkInstall, Initialize-OSDeployCorePaths, Select-OSDeployCoreBootMedia, Step-BootImageIso, Test-IsAdministrator, Write-OSDeployBannerPreview Executables: dism.exe, oscdimg.exe Windows Features: Windows ADK .LINK https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install .LINK https://github.com/RecastSoftware/RecastOSDeploy #> [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] param () #================================================= Write-OSDeployBannerPreview #================================================= # OSDeploy Requirements if (-not (Test-IsWindows11)) { throw "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] Windows 11 is required." } if (-not (Test-IsWindows1125H2)) { throw "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] Windows 11 25H2 (build 26200) is required." } if (-not (Test-PwshVersionMin)) { throw "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] PowerShell 7.4 or higher is required." } if (-not (Test-PwshPSHome)) { throw "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] The MSI installation of PowerShell 7 is required." } if (-not (Test-CommandCurl)) { throw "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] curl.exe is required but was not found in the current PATH. curl.exe ships with Windows 10 1803+." } if (-not (Test-IsAdministrator)) { throw "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] Administrator rights are required. Re-run PowerShell as Administrator and try again." } #================================================= Initialize-OSDeployCorePaths #================================================= # Select a BootImage build $SelectBootImage = Select-OSDeployCoreBootMedia if ($null -eq $SelectBootImage) { Write-Warning "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] No OSDeployCore BootImage build was found or selected" return } Write-Host -ForegroundColor DarkGray "[$(Get-Date -Format s)] Selected BootImage: $($SelectBootImage.Name)" Write-Host -ForegroundColor DarkGray "[$(Get-Date -Format s)] BootImage path: $($SelectBootImage.Path)" #================================================= # Verify Windows ADK is installed $AdkInfo = Get-OSDeployCoreWindowsAdkInstall if (-not $AdkInfo.IsInstalled) { Write-Warning "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] Windows ADK is not installed" Write-Warning "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] Install the Windows ADK from https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install" return } Write-Host -ForegroundColor DarkGray "[$(Get-Date -Format s)] Windows ADK version $($AdkInfo.InstallVersion) at $($AdkInfo.InstallPath)" #================================================= # Build media paths $MediaPath = Join-Path $SelectBootImage.Path 'bootmedia' if (-not (Test-Path -Path $MediaPath)) { Write-Warning "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] bootmedia directory not found: $MediaPath" return } $MediaPathEX = Join-Path $SelectBootImage.Path 'bootmedia_ca2023' if (-not (Test-Path -Path $MediaPathEX)) { $MediaPathEX = $null } #================================================= # Set BuildMedia global for Step-BootImageIso $global:BuildMedia = [ordered]@{ AdkRootPath = $AdkInfo.InstallPath MediaIsoLabel = $SelectBootImage.Name MediaPath = $MediaPath MediaPathEX = $MediaPathEX MediaRootPath = $SelectBootImage.Path } Write-Host -ForegroundColor DarkGray "[$(Get-Date -Format s)] MediaPath: $MediaPath" if ($MediaPathEX) { Write-Host -ForegroundColor DarkGray "[$(Get-Date -Format s)] MediaPathEX: $MediaPathEX" } Write-Host -ForegroundColor DarkGray "[$(Get-Date -Format s)] MediaRootPath: $($SelectBootImage.Path)" #================================================= if ($PSCmdlet.ShouldProcess($SelectBootImage.Path, 'Rebuild BootMedia ISO files')) { Step-BootImageIso } #================================================= Write-Verbose "[$(Get-Date -Format s)] [$($MyInvocation.MyCommand.Name)] End" #================================================= } |