description | ms.date | ms.topic | title |
---|---|---|---|
Use the PSDscResources Registry resource to remove a registry key value.
|
08/08/2022 |
reference |
Remove a registry key value |
This example shows how you can use the Registry
resource to ensure a registry key value doesn't
exist.
With Ensure set to Absent
, ValueName set to MyValue
, and Key set to
HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
, the resource removes the
MyValue
registry key value under the Environment
key if it exists.
This script shows how you can use the Registry
resource with the Invoke-DscResource
cmdlet to
ensure the Environment
registry key doesn't have a value called MyValue
.
:::code source="RemoveValue.Invoke.ps1":::
This snippet shows how you can define a Configuration
with a Registry
resource block to ensure
the Environment
registry key doesn't have a value called MyValue
.
:::code source="RemoveValue.Config.ps1":::