mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
Fixed bug with Windows Update failing to install updates for VHDX-only captures.
This commit is contained in:
@@ -207,7 +207,7 @@ param(
|
|||||||
[bool]$CopyUnattend,
|
[bool]$CopyUnattend,
|
||||||
[bool]$RemoveFFU
|
[bool]$RemoveFFU
|
||||||
)
|
)
|
||||||
$version = '2309.2'
|
$version = '2312.1'
|
||||||
|
|
||||||
#Check if Hyper-V feature is installed (requires only checks the module)
|
#Check if Hyper-V feature is installed (requires only checks the module)
|
||||||
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
|
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
|
||||||
@@ -1067,6 +1067,7 @@ function Remove-FFUVM {
|
|||||||
WriteLog "Removing VM: $VMName"
|
WriteLog "Removing VM: $VMName"
|
||||||
Remove-VM -Name $VMName -Force
|
Remove-VM -Name $VMName -Force
|
||||||
WriteLog 'Removal complete'
|
WriteLog 'Removal complete'
|
||||||
|
$VMPath = $FFUVM.Path
|
||||||
WriteLog "Removing $VMPath"
|
WriteLog "Removing $VMPath"
|
||||||
Remove-Item -Path $VMPath -Force -Recurse
|
Remove-Item -Path $VMPath -Force -Recurse
|
||||||
WriteLog 'Removal complete'
|
WriteLog 'Removal complete'
|
||||||
@@ -1119,6 +1120,9 @@ Function Remove-FFUUserShare {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Function Get-WindowsVersionInfo {
|
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"
|
WriteLog "Getting Windows Version info"
|
||||||
#Load Registry Hive
|
#Load Registry Hive
|
||||||
$Software = "$osPartitionDriveLetter`:\Windows\System32\config\software"
|
$Software = "$osPartitionDriveLetter`:\Windows\System32\config\software"
|
||||||
@@ -1157,8 +1161,6 @@ Function Get-WindowsVersionInfo {
|
|||||||
WriteLog 'Sleep 60 seconds to allow registry to completely unload'
|
WriteLog 'Sleep 60 seconds to allow registry to completely unload'
|
||||||
Start-sleep 60
|
Start-sleep 60
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return @{
|
return @{
|
||||||
|
|
||||||
DisplayVersion = $DisplayVersion
|
DisplayVersion = $DisplayVersion
|
||||||
@@ -1283,6 +1285,17 @@ Function New-DeploymentUSB {
|
|||||||
|
|
||||||
function Get-FFUEnvironment {
|
function Get-FFUEnvironment {
|
||||||
WriteLog 'Dirty.txt file detected. Last run did not complete succesfully. Will clean environment'
|
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
|
# Check for MSFT Virtual disks where location contains FFUDevelopment in the path
|
||||||
$disks = Get-Disk -FriendlyName *virtual*
|
$disks = Get-Disk -FriendlyName *virtual*
|
||||||
foreach ($disk in $disks) {
|
foreach ($disk in $disks) {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ Remove-Variable DisplayVersion
|
|||||||
Remove-Variable Office
|
Remove-Variable Office
|
||||||
reg unload "HKLM\FFU"
|
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
|
#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-sleep 60
|
||||||
Start-Process -FilePath dism.exe -ArgumentList $dismArgs -Wait -PassThru -ErrorAction Stop | Out-Null
|
Start-Process -FilePath dism.exe -ArgumentList $dismArgs -Wait -PassThru -ErrorAction Stop | Out-Null
|
||||||
#Copy DISM log to Host
|
#Copy DISM log to Host
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ $LogFileName = 'ScriptLog.txt'
|
|||||||
$USBDrive = Get-USBDrive
|
$USBDrive = Get-USBDrive
|
||||||
New-item -Path $USBDrive -Name $LogFileName -ItemType "file" -Force | Out-Null
|
New-item -Path $USBDrive -Name $LogFileName -ItemType "file" -Force | Out-Null
|
||||||
$LogFile = $USBDrive + $LogFilename
|
$LogFile = $USBDrive + $LogFilename
|
||||||
$version = '2309.2'
|
$version = '2312.1'
|
||||||
WriteLog 'Begin Logging'
|
WriteLog 'Begin Logging'
|
||||||
WriteLog "Script version: $version"
|
WriteLog "Script version: $version"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user