private/MDT/pwsh/Step-BuildMediaDismSettings.ps1
|
function Step-BuildMediaDismSettings { <# .SYNOPSIS Applies DISM locale and time-zone settings to a mounted WinPE image. .DESCRIPTION Uses dism.exe to apply the following settings to a mounted WinPE image: - Set-TimeZone : configures the default time zone. - Set-AllIntl : configures all International/locale settings. - Set-InputLocale: configures the default keyboard input locale. Each operation writes a timestamped DISM log to LogsPath. .PARAMETER MountPath Path to the directory where the WIM image is mounted. Defaults to $global:BuildMedia.MountPath. .PARAMETER LogsPath Directory where DISM log files are written. Defaults to $global:BuildMedia.LogsPath. .PARAMETER SetTimeZone Time zone name as accepted by dism /Set-TimeZone. Defaults to $global:BuildMedia.SetTimeZone. .PARAMETER SetAllIntl IETF language tag for all International settings (e.g. 'en-us'). Defaults to $global:BuildMedia.SetAllIntl. .PARAMETER SetInputLocale Input locale identifier (e.g. 'en-us'). Defaults to $global:BuildMedia.SetInputLocale. .EXAMPLE Step-BuildMediaDismSettings Applies locale and time-zone settings using values from the global BuildMedia hashtable. .EXAMPLE Step-BuildMediaDismSettings -MountPath 'C:\Mount' -SetAllIntl 'fr-fr' -SetTimeZone 'Romance Standard Time' Applies French locale settings to a WIM mounted at C:\Mount. .INPUTS None. This function does not accept pipeline input. .OUTPUTS None. .NOTES Author: David Segura Company: Recast Software Called by Invoke-OSDeployMDT during the WIM stage. #> [CmdletBinding()] param ( $MountPath = $global:BuildMedia.MountPath, $LogsPath = $global:BuildMedia.LogsPath, $SetTimeZone = $global:BuildMedia.SetTimeZone, $SetAllIntl = $global:BuildMedia.SetAllIntl, $SetInputLocale = $global:BuildMedia.SetInputLocale ) #================================================= $Error.Clear() Write-Verbose "[$(Get-Date -format s)] Start" #================================================= Write-Verbose "[$(Get-Date -format s)] MountPath: $MountPath" Write-Verbose "[$(Get-Date -format s)] LogsPath: $LogsPath" Write-Verbose "[$(Get-Date -format s)] SetAllIntl: $SetAllIntl" Write-Verbose "[$(Get-Date -format s)] SetInputLocale: $SetInputLocale" Write-Verbose "[$(Get-Date -format s)] SetTimeZone: $SetTimeZone" #================================================= Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] Set-TimeZone: $SetTimeZone" $CurrentLog = "$LogsPath\$((Get-Date).ToString('yyMMdd-HHmmss'))-Set-TimeZone.log" dism.exe /quiet /image:"$MountPath" /Set-TimeZone:"$SetTimeZone" /LogPath:"$CurrentLog" # Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] Log current Get-Intl configuration" $CurrentLog = "$LogsPath\$((Get-Date).ToString('yyMMdd-HHmmss'))-Get-Intl.log" dism.exe /quiet /image:"$MountPath" /Get-Intl /LogPath:"$CurrentLog" if ($SetAllIntl) { Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] Set-AllIntl: $SetAllIntl" $CurrentLog = "$LogsPath\$((Get-Date).ToString('yyMMdd-HHmmss'))-Set-AllIntl.log" dism.exe /quiet /image:"$MountPath" /Set-AllIntl:$SetAllIntl /LogPath:"$CurrentLog" } if ($SetInputLocale) { Write-Host -ForegroundColor DarkGray "[$(Get-Date -format s)] Set-InputLocale: $SetInputLocale" $CurrentLog = "$LogsPath\$((Get-Date).ToString('yyMMdd-HHmmss'))-Set-InputLocale.log" dism.exe /quiet /image:"$MountPath" /Set-InputLocale:$SetInputLocale /LogPath:"$CurrentLog" } #================================================= Write-Verbose "[$(Get-Date -format s)] End" #================================================= } |