-
Notifications
You must be signed in to change notification settings - Fork 1
Remove Excess ValueNames From Reg Key
Raymond Piller edited this page Apr 20, 2018
·
1 revision
Remove undesired registry values from a registry key with RegistryPlus:
RegistryPlus Remove_Excess_Values
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Test'
AllowedValueNames = @(
'My Value',
'Other Value'
)
}
This will remove all Values from the HKEY_LOCAL_MACHINE\SOFTWARE\Test
key except the two values: My Value
and Other Value
. This function will not recurse into subkeys.
If you're controlling those two values with Registry, be sure to supply DependsOn
to be sure those Values are create before doing any deletion.
Registry Set_My_Value
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Test'
ValueName = 'My Value'
ValueType = 'String'
ValueData = 'Hello World!'
}
Registry Set_Other_Value
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Test'
ValueName = 'Other Value'
ValueType = 'String'
ValueData = 'Foo Bar!'
}
RegistryPlus Remove_Excess_Values
{
Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Test'
AllowedValueNames = @(
'My Value',
'Other Value'
)
DependsOn = @(
'[Registry]Set_My_Value',
'[Registry]Set_Other_Value'
)
}
- Setting
Ensure = 'Absent'
will cause an error.