Skip to content

Commit 9f10bc5

Browse files
committed
fix: correct error message formatting in Convert-RegistryKeyToSnapshot and update tests for SkipRegistryBackup
1 parent 8346621 commit 9f10bc5

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

Scripts/Features/Backup-RegistrySnapshotCapture.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function Convert-RegistryKeyToSnapshot {
242242
foreach ($subKeyName in @($RegistryKey.GetSubKeyNames())) {
243243
$childKey = $RegistryKey.OpenSubKey($subKeyName, $false)
244244
if ($null -eq $childKey) {
245-
throw "Unable to read registry subkey '$($RegistryKey.Name)\\$subKeyName' while creating a backup snapshot. The backup was not created."
245+
throw "Unable to read registry subkey '$($RegistryKey.Name)\$subKeyName' while creating a backup snapshot. The backup was not created."
246246
}
247247

248248
try {

Tests/Import-ConfigToParams.Tests.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ BeforeAll {
33
. (Join-Path $PSScriptRoot '..\Scripts\Helpers\Add-Parameter.ps1')
44
. (Join-Path $PSScriptRoot '..\Scripts\Helpers\Import-ConfigToParams.ps1')
55
$script:ConfigFixturePath = Join-Path $PSScriptRoot 'TestData\JsonFileLoading\ExportedConfig.WithSettings.json'
6+
$script:SkipRegistryBackupFixturePath = Join-Path $PSScriptRoot 'TestData\JsonFileLoading\ExportedConfig.SkipRegistryBackup.json'
67
}
78

89
Describe 'Import-ConfigToParams' {
@@ -36,4 +37,10 @@ Describe 'Import-ConfigToParams' {
3637
$script:Params.ContainsKey('User') | Should -BeFalse
3738
$script:Params.ContainsKey('AppRemovalTarget') | Should -BeFalse
3839
}
40+
41+
It 'imports SkipRegistryBackup when deployment settings request it' {
42+
Import-ConfigToParams -ConfigPath $script:SkipRegistryBackupFixturePath -CurrentBuild 22631 | Out-Null
43+
44+
$script:Params['SkipRegistryBackup'] | Should -BeTrue
45+
}
3946
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"Version": "1.0",
3+
"Deployment": [
4+
{ "Name": "SkipRegistryBackup", "Value": true }
5+
]
6+
}

Win11Debloat.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ else {
556556

557557
# If the number of keys in ControlParams equals the number of keys in Params then no modifications/changes were selected
558558
# or added by the user, and the script can exit without making any changes.
559-
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'))) {
559+
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'))) {
560560
Write-Output "The script completed without making any changes."
561561
Wait-ForKeyPress
562562
}

0 commit comments

Comments
 (0)