Fix registry backup validation for sysprep keys

This commit is contained in:
Jeffrey
2026-05-09 21:56:58 +02:00
parent 22f3144c0f
commit c8b4563954
4 changed files with 49 additions and 9 deletions

View File

@@ -1,12 +1,13 @@
function Get-RegistryBackupCapturePlans {
param(
[Parameter(Mandatory)]
[object[]]$SelectedRegistryFeatures
[object[]]$SelectedRegistryFeatures,
[switch]$UseSysprepRegFiles
)
$planMap = @{}
foreach ($feature in $SelectedRegistryFeatures) {
$regFilePath = Get-RegistryFilePathForFeature -Feature $feature
$regFilePath = Get-RegistryFilePathForFeature -Feature $feature -UseSysprepRegFiles:$UseSysprepRegFiles
if (-not (Test-Path $regFilePath)) {
throw "Unable to find registry file for backup: $($feature.RegistryKey) ($regFilePath)"
}

View File

@@ -96,6 +96,8 @@ function Test-RegistryBackupMatchesSelectedFeatures {
[AllowEmptyCollection()]
[string[]]$SelectedFeatureIds,
[Parameter(Mandatory)]
[string]$Target,
[Parameter(Mandatory)]
[AllowEmptyCollection()]
[object[]]$RegistryKeys
)
@@ -108,10 +110,11 @@ function Test-RegistryBackupMatchesSelectedFeatures {
}
$selectedRegistryFeatures = @(Get-SelectedRegistryFeaturesForBackupValidation -SelectedFeatureIds @($SelectedFeatureIds) -Errors $errors)
$useSysprepRegFiles = ($Target -eq 'DefaultUserProfile') -or ($Target -like 'User:*')
$capturePlans = @()
if ($errors.Count -eq 0 -and $selectedRegistryFeatures.Count -gt 0) {
$capturePlans = @(Get-RegistryBackupCapturePlans -SelectedRegistryFeatures @($selectedRegistryFeatures))
$capturePlans = @(Get-RegistryBackupCapturePlans -SelectedRegistryFeatures @($selectedRegistryFeatures) -UseSysprepRegFiles:$useSysprepRegFiles)
}
$planMap = New-RegistryBackupAllowListPlanMap -CapturePlans @($capturePlans)

View File

@@ -87,7 +87,7 @@ function Normalize-RegistryBackup {
$errors.Add([string]$selectedFeatureParseError)
}
$allowListValidationErrors = @(Test-RegistryBackupMatchesSelectedFeatures -SelectedFeatureIds @($selectedFeatures) -RegistryKeys @($normalizedKeys))
$allowListValidationErrors = @(Test-RegistryBackupMatchesSelectedFeatures -SelectedFeatureIds @($selectedFeatures) -Target $normalizedTarget -RegistryKeys @($normalizedKeys))
foreach ($allowListValidationError in $allowListValidationErrors) {
$errors.Add([string]$allowListValidationError)
}