Example: removing a value under a registry key
The following simple example uses
new-item
to create a
registry key, then adds three values to that key and pauses (
read-host
) to check the registry.
After hitting enter, the value
xyz
is removed and the script pauses again to verify that the
value was indeed remove.
$regKey = 'hkcu:\Software\tq84_removeItemTest'
$null = new-item $regKey
set-itemProperty $regKey num 42
set-itemProperty $regKey txt 'Hello world'
set-itemProperty $regKey xyz 'Foo, bar, baz'
read-host 'Registry key and values created.'
remove-itemProperty $regKey xyz
read-host 'Value "xyz" removed.'
remove-item $regKey