private/BootMedia/Steps/Step-BootImageCopyOSDModule.ps1
|
#Requires -PSEdition Core function Step-BootImageCopyOSDModule { <# .SYNOPSIS Copies the OSD PowerShell module into the mounted WinPE image. .NOTES Author: David Segura Version: 0.1.0 #> [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-OSDModulePath is not available. OSD module is not installed. Skipping.' return } $ModuleSource = Get-OSDModulePath if (-not $ModuleSource -or -not (Test-Path $ModuleSource)) { Write-Warning "OSD module path not found: $ModuleSource" return } $ModuleVersion = (Get-OSDModuleVersion).ToString() $ModuleDestination = "$MountPath\Program Files\WindowsPowerShell\Modules\OSD\$ModuleVersion" Write-OSDeployCoreProgress "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-OSDeployCoreProgress "OSD module v$ModuleVersion injected into $ModuleDestination" $global:BuildMedia.InstalledApps += "OSD $ModuleVersion" } else { Write-Warning "OSD module copy may have failed. Expected manifest at $ModuleDestination\OSD.psd1" } } |