有关二进制注册表项的 DSC 语法的附加信息请求

有关二进制注册表项的 DSC 语法的附加信息请求

我对实施以下解决方案还有更多疑问:二进制注册表项的 DSC 语法

Matthew Whetmore 建议的解决方案在大多数情况下都有效……但如果数据以“00”开头,它就会不知何故被丢弃。例如对于此数据:

$reg = "00,01,04,80,64,00,00,00,70,00,00,00,00,00,00,00,
  14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,03,00,0f,00,01,02,00,00,00,
  00,00,05,20,00,00,00,20,02,00,00,00,00,18,00,03,00,0f,00,01,02,00,00,00,00,
  00,05,20,00,00,00,25,02,00,00,00,00,18,00,03,00,0f,00,01,02,00,00,00,00,00,
  05,20,00,00,00,27,02,00,00,01,01,00,00,00,00,00,05,12,00,00,00,01,01,00,00,
  00,00,00,05,12,00,00,00"

当 DSC 将第一组 00 添加到注册表时,它会被删除,注册表中的值会以“01 04 ...”开头。看起来像是正在进行一次完整的左移。注册表中存储的字节数比原始值少一个。

还有人看到这个异常吗?可以修复吗?提前致谢。

答案1

给出你的起始字符串:

$reg = "00,01,04,80,64,00,00,00,70,00,00,00,00,00,00,00,
  14,00,00,00,02,00,50,00,03,00,00,00,00,00,18,00,03,00,0f,00,01,02,00,00,00,
  00,00,05,20,00,00,00,20,02,00,00,00,00,18,00,03,00,0f,00,01,02,00,00,00,00,
  00,05,20,00,00,00,25,02,00,00,00,00,18,00,03,00,0f,00,01,02,00,00,00,00,00,
  05,20,00,00,00,27,02,00,00,01,01,00,00,00,00,00,05,12,00,00,00,01,01,00,00,
  00,00,00,05,12,00,00,00"

下一步是格式化字符串基本上删除空格和逗号:

$val = [String]::Join("",$reg.Split(",").Trim())

然后,$val是您想要写入注册表的变量。

相关内容