DSC-Resource:如何删除注册表项(不是值)?

Mat*_*ert 5 powershell dsc

我知道我可以通过使用以下脚本块来确保特定注册表值的存在:

    Registry ConfigureRegistry
    {
        Ensure    = 'Present'
        Key       = 'HKEY_LOCAL_MACHINE\SOFTWARE\SomeKey'
        ValueName = 'MachineType'
        ValueData = 'Hyper-V'
    }
Run Code Online (Sandbox Code Playgroud)

但是如何删除注册表项SomeKey?如果我只将关键字更改Ensure = "Present"Ensure = "Absent"它会留下密钥SomeKey......

bri*_*ist 3

现在这是可能的,请参阅 VertigoRay 的答案。

正如您所发现的,目前该资源还不可能实现这一点Registry

您可以使用Script资源或编写完整的自定义资源。