Refactor BuildFFUVM.ps1 script***

This commit refactors the BuildFFUVM.ps1 script by:
- Changing the default value of FFUDevelopmentPath to $PSScriptRoot
- Adding a new parameter RemoveFFU
- Adding a new function Remove-FFU to remove all FFU files in the FFUCaptureLocation
- Adding a conditional block to call Remove-FFU if RemoveFFU parameter is true
This commit is contained in:
rbalsleyMSFT
2024-02-16 10:38:42 -08:00
parent 1c38556e32
commit a4cd349f45
+21 -3
View File
@@ -125,7 +125,7 @@ param(
})] })]
[string]$WindowsSKU = 'Pro', [string]$WindowsSKU = 'Pro',
[ValidateScript({ Test-Path $_ })] [ValidateScript({ Test-Path $_ })]
[string]$FFUDevelopmentPath = 'C:\FFUDevelopment', [string]$FFUDevelopmentPath = $PSScriptRoot,
[bool]$InstallApps, [bool]$InstallApps,
[bool]$InstallOffice, [bool]$InstallOffice,
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
@@ -210,10 +210,11 @@ param(
return $true return $true
})] })]
[bool]$CopyDrivers, [bool]$CopyDrivers,
[bool]$RemoveFFU,
#Will be used in future release #Will be used in future release
[bool]$CopyPPKG, [bool]$CopyPPKG,
[bool]$CopyUnattend, [bool]$CopyUnattend
[bool]$RemoveFFU
) )
$version = '2402.1' $version = '2402.1'
@@ -1392,6 +1393,12 @@ function Get-FFUEnvironment {
Remove-Item -Path "$FFUDevelopmentPath\dirty.txt" -Force Remove-Item -Path "$FFUDevelopmentPath\dirty.txt" -Force
WriteLog "Cleanup complete" WriteLog "Cleanup complete"
} }
function Remove-FFU{
#Remove all FFU files in the FFUCaptureLocation
WriteLog "Removing all FFU files in $FFUCaptureLocation"
Remove-Item -Path $FFUCaptureLocation\*.ffu -Force
WriteLog "Removal complete"
}
###END FUNCTIONS ###END FUNCTIONS
@@ -1706,6 +1713,17 @@ If ($BuildUSBDrive) {
throw $_ throw $_
} }
} }
If ($RemoveFFU){
try {
Remove-FFU
}
catch {
Write-Host 'Removing FFU files failed'
Writelog "Removing FFU files failed with error $_"
throw $_
}
}
#Clean up dirty.txt file #Clean up dirty.txt file
Remove-Item -Path .\dirty.txt -Force | out-null Remove-Item -Path .\dirty.txt -Force | out-null
Write-Host "Script complete" Write-Host "Script complete"