0

I have more questions about implementing the solution found in: DSC Syntax for Binary Registry Key

For the most part the solution suggested by Matthew Whetmore worked... but if the data starts with "00", somehow it is getting dropped. For e.g. for this data:

$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"

The first set of 00 gets dropped when DSC adds it to the Registry, and the value in the registry starts with "01 04 ...". Looks like a whole left shift going on. The number of bytes stored in the registry is one less the original.

Any one else seeing this anomaly, and possible a fix? Thanks in advance.

SamErde
  • 3,324
  • 3
  • 23
  • 42
Krish MD
  • 1
  • 1
  • Can you be more specific about what PowerShell lines you have used to save this data as a variable and write it to the registry? – SamErde Jun 01 '21 at 14:55

1 Answers1

0

Given your starting string:

$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"

The next step is to format the string by basically removing the spaces and commas:

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

Then, $val is the variable that you'll want to write to the registry.

SamErde
  • 3,324
  • 3
  • 23
  • 42