Merge branch '2407.1' of https://github.com/rbalsleyMSFT/FFU into 2407.1

This commit is contained in:
rbalsleyMSFT
2024-07-18 21:35:18 -07:00
@@ -430,8 +430,10 @@ Writelog 'Clean Disk'
#Invoke-Process diskpart.exe "/S $UEFIFFUPartitions" #Invoke-Process diskpart.exe "/S $UEFIFFUPartitions"
try { try {
$Disk = Get-Disk -Number $DiskID $Disk = Get-Disk -Number $DiskID
if ($Disk.PartitionStyle -ne "RAW") {
$Disk | clear-disk -RemoveData -RemoveOEM -Confirm:$false $Disk | clear-disk -RemoveData -RemoveOEM -Confirm:$false
} }
}
catch { catch {
WriteLog 'Cleaning disk failed. Exiting' WriteLog 'Cleaning disk failed. Exiting'
throw $_ throw $_
@@ -444,6 +446,16 @@ WriteLog "Applying FFU to $PhysicalDeviceID"
WriteLog "Running command dism /apply-ffu /ImageFile:$FFUFileToInstall /ApplyDrive:$PhysicalDeviceID" WriteLog "Running command dism /apply-ffu /ImageFile:$FFUFileToInstall /ApplyDrive:$PhysicalDeviceID"
#In order for Applying Image progress bar to show up, need to call dism directly. Might be a better way to handle, but must have progress bar show up on screen. #In order for Applying Image progress bar to show up, need to call dism directly. Might be a better way to handle, but must have progress bar show up on screen.
dism /apply-ffu /ImageFile:$FFUFileToInstall /ApplyDrive:$PhysicalDeviceID dism /apply-ffu /ImageFile:$FFUFileToInstall /ApplyDrive:$PhysicalDeviceID
$recoveryPartition = Get-Partition -Disk $Disk | Where-Object PartitionNumber -eq 4
if ($recoveryPartition) {
$diskpartScript = @(
"SELECT DISK $($Disk.Number)",
"SELECT PARTITION $($recoveryPartition.PartitionNumber)",
"GPT ATTRIBUTES=0x8000000000000001",
"EXIT"
)
$diskpartScript | diskpart.exe
}
if($LASTEXITCODE -eq 0){ if($LASTEXITCODE -eq 0){
WriteLog 'Successfully applied FFU' WriteLog 'Successfully applied FFU'
} }