mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Adds cleanup for disabled update artifacts
Introduces a new function to remove residual artifacts for updates that are disabled via script flags. If updates for Defender, MSRT, OneDrive, or Edge are turned off, this change ensures that any related files are deleted from the build environment. This prevents unnecessary files from being included in the final image.
This commit is contained in:
@@ -3597,6 +3597,71 @@ function Remove-FFU {
|
||||
Remove-Item -Path $FFUCaptureLocation\*.ffu -Force
|
||||
WriteLog "Removal complete"
|
||||
}
|
||||
Function Remove-DisabledUpdates {
|
||||
# Remove Defender artifacts if Defender update is disabled
|
||||
if (-not $UpdateLatestDefender) {
|
||||
$removed = $false
|
||||
if (Test-Path -Path $installDefenderPath) {
|
||||
WriteLog "Update Defender disabled - removing $installDefenderPath"
|
||||
Remove-Item -Path $installDefenderPath -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if (Test-Path -Path $DefenderPath) {
|
||||
WriteLog "Update Defender disabled - removing $DefenderPath"
|
||||
Remove-Item -Path $DefenderPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if ($removed) { WriteLog 'Removal complete' }
|
||||
}
|
||||
|
||||
# Remove MSRT artifacts if MSRT update is disabled
|
||||
if (-not $UpdateLatestMSRT) {
|
||||
$removed = $false
|
||||
if (Test-Path -Path $installMSRTPath) {
|
||||
WriteLog "Update MSRT disabled - removing $installMSRTPath"
|
||||
Remove-Item -Path $installMSRTPath -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if (Test-Path -Path $MSRTPath) {
|
||||
WriteLog "Update MSRT disabled - removing $MSRTPath"
|
||||
Remove-Item -Path $MSRTPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if ($removed) { WriteLog 'Removal complete' }
|
||||
}
|
||||
|
||||
# Remove OneDrive artifacts if OneDrive update is disabled
|
||||
if (-not $UpdateOneDrive) {
|
||||
$removed = $false
|
||||
if (Test-Path -Path $installODPath) {
|
||||
WriteLog "Update OneDrive disabled - removing $installODPath"
|
||||
Remove-Item -Path $installODPath -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if (Test-Path -Path $OneDrivePath) {
|
||||
WriteLog "Update OneDrive disabled - removing $OneDrivePath"
|
||||
Remove-Item -Path $OneDrivePath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if ($removed) { WriteLog 'Removal complete' }
|
||||
}
|
||||
|
||||
# Remove Edge artifacts if Edge update is disabled
|
||||
if (-not $UpdateEdge) {
|
||||
$removed = $false
|
||||
if (Test-Path -Path $installEdgePath) {
|
||||
WriteLog "Update Edge disabled - removing $installEdgePath"
|
||||
Remove-Item -Path $installEdgePath -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if (Test-Path -Path $EdgePath) {
|
||||
WriteLog "Update Edge disabled - removing $EdgePath"
|
||||
Remove-Item -Path $EdgePath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
$removed = $true
|
||||
}
|
||||
if ($removed) { WriteLog 'Removal complete' }
|
||||
}
|
||||
}
|
||||
|
||||
Function Remove-Updates {
|
||||
if ($UpdateLatestDefender) {
|
||||
@@ -4887,6 +4952,10 @@ if ($InstallApps) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Remove residual update artifacts for any updates disabled via flags
|
||||
Remove-DisabledUpdates
|
||||
|
||||
#Update Latest Defender Platform and Definitions - these can't be serviced into the VHDX, will be saved to AppsPath
|
||||
if ($UpdateLatestDefender) {
|
||||
# Check if Defender has already been downloaded, if so, skip download
|
||||
|
||||
Reference in New Issue
Block a user