mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-07-20 21:10:20 +08:00
fix: correct error message formatting in Convert-RegistryKeyToSnapshot and update tests for SkipRegistryBackup
This commit is contained in:
parent
83466219eb
commit
9f10bc56ff
@ -242,7 +242,7 @@ function Convert-RegistryKeyToSnapshot {
|
||||
foreach ($subKeyName in @($RegistryKey.GetSubKeyNames())) {
|
||||
$childKey = $RegistryKey.OpenSubKey($subKeyName, $false)
|
||||
if ($null -eq $childKey) {
|
||||
throw "Unable to read registry subkey '$($RegistryKey.Name)\\$subKeyName' while creating a backup snapshot. The backup was not created."
|
||||
throw "Unable to read registry subkey '$($RegistryKey.Name)\$subKeyName' while creating a backup snapshot. The backup was not created."
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@ -3,6 +3,7 @@ BeforeAll {
|
||||
. (Join-Path $PSScriptRoot '..\Scripts\Helpers\Add-Parameter.ps1')
|
||||
. (Join-Path $PSScriptRoot '..\Scripts\Helpers\Import-ConfigToParams.ps1')
|
||||
$script:ConfigFixturePath = Join-Path $PSScriptRoot 'TestData\JsonFileLoading\ExportedConfig.WithSettings.json'
|
||||
$script:SkipRegistryBackupFixturePath = Join-Path $PSScriptRoot 'TestData\JsonFileLoading\ExportedConfig.SkipRegistryBackup.json'
|
||||
}
|
||||
|
||||
Describe 'Import-ConfigToParams' {
|
||||
@ -36,4 +37,10 @@ Describe 'Import-ConfigToParams' {
|
||||
$script:Params.ContainsKey('User') | Should -BeFalse
|
||||
$script:Params.ContainsKey('AppRemovalTarget') | Should -BeFalse
|
||||
}
|
||||
|
||||
It 'imports SkipRegistryBackup when deployment settings request it' {
|
||||
Import-ConfigToParams -ConfigPath $script:SkipRegistryBackupFixturePath -CurrentBuild 22631 | Out-Null
|
||||
|
||||
$script:Params['SkipRegistryBackup'] | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"Version": "1.0",
|
||||
"Deployment": [
|
||||
{ "Name": "SkipRegistryBackup", "Value": true }
|
||||
]
|
||||
}
|
||||
@ -556,7 +556,7 @@ else {
|
||||
|
||||
# If the number of keys in ControlParams equals the number of keys in Params then no modifications/changes were selected
|
||||
# or added by the user, and the script can exit without making any changes.
|
||||
if (($controlParamsCount -eq $script:Params.Keys.Count) -or ($script:Params.Keys.Count -eq 1 -and ($script:Params.Keys -contains 'CreateRestorePoint' -or $script:Params.Keys -contains 'SkipRegistryBackup' -or $script:Params.Keys -contains 'Apps'))) {
|
||||
if (($controlParamsCount -eq $script:Params.Keys.Count) -or ($script:Params.Keys.Count -eq 1 -and ($script:Params.Keys -contains 'CreateRestorePoint' -or $script:Params.Keys -contains 'Apps'))) {
|
||||
Write-Output "The script completed without making any changes."
|
||||
Wait-ForKeyPress
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user