private/Set-OSDeployBootProfileWallpaper.ps1
|
#Requires -PSEdition Core function Set-OSDeployBootProfileWallpaper { <# .SYNOPSIS Selects and saves a shared wallpaper for an OSDeploy Boot profile .DESCRIPTION Selects a JPG from the shared Boot-Assets boot-wallpaper library and copies it into the specified profile. A single shared JPG is selected automatically. Multiple JPG files are displayed in a single-selection Out-GridView picker. Canceling the picker leaves any existing profile wallpaper unchanged. .PARAMETER ProfilePath Specifies the profile directory that contains osdeployboot.json. .EXAMPLE PS> Set-OSDeployBootProfileWallpaper -ProfilePath 'C:\ProgramData\OSDeployCore\boot-assets\osdeployboot-profiles\Contoso-amd64' Selects and saves a shared wallpaper for Contoso-amd64. .INPUTS None. This function does not accept pipeline input. .OUTPUTS None. .NOTES Author: David Segura Company: Recast Software Version: 1.0.0 Date: 2026-09-03 #> [CmdletBinding()] param ( [Parameter(Mandatory)] [System.String] $ProfilePath ) $WallpaperPath = Join-Path $Script:OSDeployBootAssetsPath 'boot-wallpaper' $WallpaperFiles = @(Get-ChildItem -LiteralPath $WallpaperPath -Filter '*.jpg' -File -ErrorAction SilentlyContinue | Sort-Object FullName) $SelectedWallpaper = $null if ($WallpaperFiles.Count -eq 1) { $SelectedWallpaper = $WallpaperFiles[0] } elseif ($WallpaperFiles.Count -gt 1) { $SelectedWallpaper = $WallpaperFiles | Select-Object Name, FullName | Out-GridView -Title 'Select Wallpaper to add to this build' -OutputMode Single } if (-not $SelectedWallpaper) { return } $Destination = Join-Path $ProfilePath 'wallpaper.jpg' Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] [INFO] Saving selected wallpaper to $Destination" Copy-Item -LiteralPath $SelectedWallpaper.FullName -Destination $Destination -Force } |