description | ms.date | ms.topic | title |
---|---|---|---|
Use the PSDscResources Registry resource to add a registry key.
|
08/08/2022 |
reference |
Add a registry key |
This example shows how you can use the Registry
resource to ensure a registry key exists.
With Ensure set to Present
, ValueName set to an empty string, and Key set to
HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\MyNewKey
, the resource adds the
MyNewKey
registry key if it doesn't exist.
This script shows how you can use the Registry
resource with the Invoke-DscResource
cmdlet to
ensure the MyNewKey
registry key exists.
:::code source="AddKey.Invoke.ps1":::
This snippet shows how you can define a Configuration
with a Registry
resource block to ensure
the MyNewKey
registry key exists.
:::code source="AddKey.Config.ps1":::