Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Push a LayoutModification.xml file into a WIM prior to installation.
Update the Start Menu layout in a WIM file
Update the Start Menu layout in a WIM file
The path to the WIM image file (typically install.wim)
.PARAMETER LayoutModification
The path to the Start Layout created by running:
Export-StartLayout -Path C:\LayoutModification.xml
.\Update-StartLayoutInWim.ps1 -Wim C:\Install.wim -Layout C:\LayoutModification.xml
param (
[Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true)]
[Parameter(Mandatory=$true, Position=2)]
begin {
$LayoutModification = Get-Item -Path $LayoutModification `
-ErrorAction Stop
$StartDate = Get-Date
$TempDirectory = New-Item -Path "$env:TEMP\$($StartDate.ToString('yyyyMMddHHmmss'))" `
-ItemType Directory
Write-Verbose "Start Time: $StartDate"
Write-Verbose "Temporary Directory: $TempDirectory"
process {
foreach ( $Item in $Path ) {
$Item = Get-Item -Path $Item -ErrorAction Stop
Write-Host "Updating 'LayoutModification.xml' in '$($Item.FullName)'..." -ForegroundColor Yellow
Write-Host "Mounting Windows Image"
Mount-WindowsImage -Path $TempDirectory `
-ImagePath $Item `
-Index $Index
Write-Host "Updating Start Layout"
Copy-Item -Path $LayoutModification `
-Destination "$TempDirectory\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.xml" `
-Force `
Write-Host "Dismounting Windows Image"
Dismount-WindowsImage -Path $TempDirectory `
-Save `
if ( $PassThru.IsPresent ) {
Get-Item -Path $Item
end {
Write-Host "Cleaning Up Environment"
$TempDirectory | Remove-Item -Recurse `
-Force `
-Confirm:$false `
> $null
Write-Verbose "End Time: $((Get-Date).ToString())"
Copy link

WileC commented Jun 25, 2020


The example line might be:
.\Update-StartLayoutInWim.ps1 -Path C:\Install.wim -LayoutModification C:\LayoutModification.xml

Is there a way, to update all indexes in a wim-file? In my wim-files there's index 1 "Windows Home", index 2 "Windows Education" and index 3 "Windows Pro" ... and so on.

I would like to update all LayoutModifications in all wim indexes..


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment