From 1921809c3032392d6fa14a51451713b7ae414c06 Mon Sep 17 00:00:00 2001 From: MKellyCBSD <167896478+MKellyCBSD@users.noreply.github.com> Date: Wed, 15 May 2024 15:42:00 -0400 Subject: [PATCH 1/2] Update InstallAppsandSysprep.cmd Remove this command because moving it up right after updates are applied to the scratch VHDX saves ~650MB on the final .ffu file. --- FFUDevelopment/Apps/InstallAppsandSysprep.cmd | 3 --- 1 file changed, 3 deletions(-) diff --git a/FFUDevelopment/Apps/InstallAppsandSysprep.cmd b/FFUDevelopment/Apps/InstallAppsandSysprep.cmd index 1d2e97f..b617bd7 100644 --- a/FFUDevelopment/Apps/InstallAppsandSysprep.cmd +++ b/FFUDevelopment/Apps/InstallAppsandSysprep.cmd @@ -15,8 +15,5 @@ del c:\windows\panther\unattend\unattend.xml /F /Q del c:\windows\panther\unattend.xml /F /Q taskkill /IM sysprep.exe timeout /t 10 -REM Run Component Cleanup since dism /online /cleanup-image /analyzecomponentcleanup recommends it -REM If adding latest CU, definitely need to do this to keep FFU size smaller -dism /online /cleanup-image /startcomponentcleanup /resetbase REM Sysprep/Generalize c:\windows\system32\sysprep\sysprep.exe /quiet /generalize /oobe From 3f4836b47826b2fd9210f9abd42c34f54fcc2a4a Mon Sep 17 00:00:00 2001 From: MKellyCBSD <167896478+MKellyCBSD@users.noreply.github.com> Date: Wed, 15 May 2024 15:52:38 -0400 Subject: [PATCH 2/2] Update BuildFFUVM.ps1 Adding "-PreventPending" to the "add-windowspackage" command allows the dism cleanup of the winsxs folder command to be moved from the InstallAppsandSysprep.cmd script to right after the updates are added to the vhdx. The end result: FFU image size before: 11.836GB FFU image size after: 11.190GB --- FFUDevelopment/BuildFFUVM.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index 7a24450..0258969 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -2240,10 +2240,13 @@ try { if ($UpdateLatestCU -or $UpdateLatestNet) { try { WriteLog "Adding KBs to $WindowsPartition" - Add-WindowsPackage -Path $WindowsPartition -PackagePath $KBPath | Out-Null + Add-WindowsPackage -Path $WindowsPartition -PackagePath $KBPath -PreventPending | Out-Null WriteLog "KBs added to $WindowsPartition" WriteLog "Removing $KBPath" Remove-Item -Path $KBPath -Recurse -Force | Out-Null + WriteLog "Clean Up the WinSxS Folder" + Dism /Image:$WindowsPartition /Cleanup-Image /StartComponentCleanup /ResetBase | Out-Null + WriteLog "Clean Up the WinSxS Folder completed" } catch { Write-Host "Adding KB to VHDX failed with error $_" @@ -2498,4 +2501,4 @@ If ($CleanupAppsISO) { #Clean up dirty.txt file Remove-Item -Path .\dirty.txt -Force | out-null Write-Host "Script complete" -WriteLog "Script complete" \ No newline at end of file +WriteLog "Script complete"