diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index c412f69..a506855 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -207,7 +207,7 @@ param( [bool]$CopyUnattend, [bool]$RemoveFFU ) -$version = '2309.2' +$version = '2312.1' #Check if Hyper-V feature is installed (requires only checks the module) $osInfo = Get-WmiObject -Class Win32_OperatingSystem @@ -1067,6 +1067,7 @@ function Remove-FFUVM { WriteLog "Removing VM: $VMName" Remove-VM -Name $VMName -Force WriteLog 'Removal complete' + $VMPath = $FFUVM.Path WriteLog "Removing $VMPath" Remove-Item -Path $VMPath -Force -Recurse WriteLog 'Removal complete' @@ -1119,6 +1120,9 @@ Function Remove-FFUUserShare { } Function Get-WindowsVersionInfo { + #This sleep prevents CBS/CSI corruption which causes issues with Windows update after deployment. Capturing from very fast disks (NVME) can cause the capture to happen faster than Windows is ready for. This seems to affect VHDX-only captures, not VM captures. + WriteLog 'Sleep 60 seconds before opening registry to grab Windows version info ' + Start-sleep 60 WriteLog "Getting Windows Version info" #Load Registry Hive $Software = "$osPartitionDriveLetter`:\Windows\System32\config\software" @@ -1157,8 +1161,6 @@ Function Get-WindowsVersionInfo { WriteLog 'Sleep 60 seconds to allow registry to completely unload' Start-sleep 60 - - return @{ DisplayVersion = $DisplayVersion @@ -1283,6 +1285,17 @@ Function New-DeploymentUSB { function Get-FFUEnvironment { WriteLog 'Dirty.txt file detected. Last run did not complete succesfully. Will clean environment' + # Check for running VMs that start with '_FFU-' and are in the 'Off' state + $vms = Get-VM + + # Loop through each VM + foreach ($vm in $vms) { + # Check if the VM name starts with '_FFU-' and the state is 'Off' + if ($vm.Name.StartsWith("_FFU-") -and $vm.State -eq 'Off') { + # If conditions are met, delete the VM + Remove-FFUVM -VMName $vm.Name + } + } # Check for MSFT Virtual disks where location contains FFUDevelopment in the path $disks = Get-Disk -FriendlyName *virtual* foreach ($disk in $disks) { diff --git a/FFUDevelopment/WinPECaptureFFUFiles/CaptureFFU.ps1 b/FFUDevelopment/WinPECaptureFFUFiles/CaptureFFU.ps1 index c0021c9..fb4b964 100644 --- a/FFUDevelopment/WinPECaptureFFUFiles/CaptureFFU.ps1 +++ b/FFUDevelopment/WinPECaptureFFUFiles/CaptureFFU.ps1 @@ -60,6 +60,7 @@ Remove-Variable DisplayVersion Remove-Variable Office reg unload "HKLM\FFU" #This prevents Critical Process Died errors you can have during deployment of the FFU - may not happen during capture from WinPE, but adding here to be consistent with VHDX capture +Write-Host "Sleeping for 60 seconds to allow registry to unload prior to capture" Start-sleep 60 Start-Process -FilePath dism.exe -ArgumentList $dismArgs -Wait -PassThru -ErrorAction Stop | Out-Null #Copy DISM log to Host diff --git a/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 b/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 index 7284a4a..c6ba754 100644 --- a/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 +++ b/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 @@ -117,7 +117,7 @@ $LogFileName = 'ScriptLog.txt' $USBDrive = Get-USBDrive New-item -Path $USBDrive -Name $LogFileName -ItemType "file" -Force | Out-Null $LogFile = $USBDrive + $LogFilename -$version = '2309.2' +$version = '2312.1' WriteLog 'Begin Logging' WriteLog "Script version: $version"