private/Step-BuildBootCopyOSDModule.ps1
|
#Requires -PSEdition Core function Step-BuildBootCopyOSDModule { <# .SYNOPSIS Copies the installed OSD module into the mounted WinPE image .DESCRIPTION Resolves the installed OSD module path and version, creates its versioned destination under the mounted image, and copies the module with robocopy.exe. The copy log is appended in the build log directory. The function skips the copy with a warning when Get-OSDModulePath is unavailable or the resolved source does not exist. After a successful manifest check, it appends the installed OSD version to global BuildMedia.InstalledApps. .EXAMPLE PS> Step-BuildBootCopyOSDModule Copies the available OSD module into the mounted WinPE module path. .INPUTS None. This function does not accept pipeline input. .OUTPUTS None. robocopy.exe output is redirected to a log file and suppressed. .NOTES Author: David Segura Company: Recast Software Version: 0.1.0 Date: 2026-08-28 Requires global BuildMedia with MountPath, LogsPath, and InstalledApps properties, the OSD commands Get-OSDModulePath and Get-OSDModuleVersion, and robocopy.exe. Modifies the mounted image and global BuildMedia.InstalledApps. #> [CmdletBinding()] param () $MountPath = $global:BuildMedia.MountPath $LogsPath = $global:BuildMedia.LogsPath # Require Get-OSDModulePath to be available if (-not (Get-Command -Name 'Get-OSDModulePath' -ErrorAction SilentlyContinue)) { Write-Warning "[$(Get-Date -Format s)] Get-OSDModulePath is not available. OSD module is not installed. Skipping." return } $ModuleSource = Get-OSDModulePath if (-not $ModuleSource -or -not (Test-Path $ModuleSource)) { Write-Warning "[$(Get-Date -Format s)] OSD module path not found: $ModuleSource" return } $ModuleVersion = (Get-OSDModuleVersion).ToString() $ModuleDestination = "$MountPath\Program Files\WindowsPowerShell\Modules\OSD\$ModuleVersion" Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [INFO] Copying OSD module v$ModuleVersion from $ModuleSource" if (-not (Test-Path $ModuleDestination)) { New-Item -Path $ModuleDestination -ItemType Directory -Force | Out-Null } $CurrentLog = "$LogsPath\$((Get-Date).ToString('yyMMdd-HHmmss'))-Copy-OSDModule.log" $null = robocopy.exe "$ModuleSource" "$ModuleDestination" *.* /e /b /ndl /nfl /np /ts /r:0 /w:0 /xj /mt:128 /XD .git .github .vscode /LOG+:"$CurrentLog" if (Test-Path "$ModuleDestination\OSD.psd1") { Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [INFO] OSD module v$ModuleVersion injected into $ModuleDestination" $global:BuildMedia.InstalledApps += "OSD $ModuleVersion" } else { Write-Warning "[$(Get-Date -Format s)] OSD module copy may have failed. Expected manifest at $ModuleDestination\OSD.psd1" } } |