Merge WSUS Updates Into a WIM Image Using PowerShell 3.0
# The path to the WIM Image file
$imagePath = "C:\\users\\administrator\\desktop\\windows7.wim"
# The path to the root of your WSUS Content
$wsusContent = "C:\\WSUS\WsusContent"
# The index in the WIM file to the OS image you want to mount.
$imageIndex = 1
# The directory where you want to mount the WIM Image
$mountPath = "C:\\Mount"
# Mount the WIM Image to the mount point specified,
Mount-WindowsImage -ImagePath $imagePath -Index $imageIndex -Path $mountPath -Optimize
# Get a list of all subdirectories under WsusContent
$paths = Get-ChildItem $wsusContent -Directory
# Iterate through each WsusContent subdirectory and attempt to add all
# Windows Packages found there.
foreach( $item in $paths ) {
Add-WindowsPackage -Path $mountPath -PackagePath $wsusContent\$item -IgnoreCheck
}
# Save and dismount the Windows image.
Dismount-WindowsImage -Path $mountPath -Save