Set-RegistryKey – trying to create Binary value

//Set-RegistryKey – trying to create Binary value
Set-RegistryKey – trying to create Binary value 2016-07-15T14:40:35+00:00

The Toolkit Forums General Set-RegistryKey – trying to create Binary value

  • Author
    Posts
  • Jacob
    Participant
    Post count: 7
    #1458 |

    Hey folks. So I’m setting up values for an Office deployment and I was wondering what you do for REG_BINARY values. I have one that appears like so:

    [HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033\Option Set 0]
    “Data”=hex:01,01,01,01,01,01,01,01,01,01,01,01,02,01,01,01,01,01,01,01,02,01,\
    01,01,01,01,01,01,00,01,01,01,02,02,02

    And I’ve tried to input it like so:

    Set-RegistryKey -Key ‘HKCU\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033\Option Set 0’ -Name ‘Data’ -Value 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x02,0x02,0x02-Type Binary -SID $UserProfile.SID

    This doesn’t work… what am I doing wrong? Am I supposed to include the slash character somehow?

  • matthew
    Participant
    Post count: 4

    I will show you an easier way. This is how I do almost everything. you can use the free version and push via sccm

    I used the free version and then bought real one . Free version will do almost everything. I just wanted to support the person.

    http://www.exetomsi.com/

    Just pick an exe and make a new program. Then when it makes a file you can then just delete the exe file. Then create the registry keys. Then just compile it. SCCM loves it as it is an msi .

  • matthew
    Participant
    Post count: 4

    You can create a fake exe using autoit and just compile a small program. Then just delete it. Then you can make registry keys very easy and add files ETC>

  • Jacob
    Participant
    Post count: 7

    Huh? I can make an MSI with AdminStudio, it just sucks because it’s hard to repair the keys unless you do some terrible ActiveSetup modifications.

    I managed to get the REG_BINARY thing working… turns out what it didn’t like was the -SID $UserProfile.SID bit, which is odd. Now the scriptblock is failing because it thinks I’m trying to declare “ContinueOnError” for one of the Set-RegistryKey commands. Very weird stuff here.

  • That_annoying_guy
    Participant
    Post count: 42

    If you get it working (Or not), Ask the developers to add it as an example to Set-RegistryKey.

    I’m impressed you figured out a way to make it work.

  • Jacob
    Participant
    Post count: 7

    Okay, so in the end I wasn’t able to get this cmdlet to work. It kept erroring out. I was on the verge of making a batch file for every shortcut and replacing the shortcuts with that file (just to make sure every user had the correct settings in HKCU before launching any of the applications) when I found this article: https://blogs.technet.microsoft.com/deploymentguys/2011/05/31/deploying-custom-registry-settings-for-office-2010/

    So I went with that. It works pretty well and I just need to modify HKLM.

  • Eric
    Participant
    Post count: 2

    Hi, sorry for my bad English.
    if you want use HKCU for all user profil that exist on your computer, you must use this syntax :

    [scriptblock]$HKCURegistrySettings = {
    Set-RegistryKey -Key ‘HKCU\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033\Option Set 0’ -Name ‘Data’ -Value 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x02,0x02,0x02 -Type Binary -SID $UserProfile.SID
    }
    Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings

    Else, if you want put entry for a specidfic user :

    Set-RegistryKey -Key ‘HKCU\Software\Microsoft\Shared Tools\Proofing Tools\Grammar\MSGrammar\3.0\1033\Option Set 0’ -Name ‘Data’ -Value 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x01,0x01,0x01,0x02,0x02,0x02 -Type Binary -SID $((ConvertTo-NTAccountOrSID -AccountName ‘CONTOSO\User1’).value)

    • This reply was modified 1 year, 3 months ago by  Eric.
  • Aldin
    Participant
    Post count: 12

    This is how I did it once for Google Earth for all existing AND FUTURE users:

    $RegPath = ‘HKCU\SOFTWARE\Google\Google Earth Pro’
    $ADataValueHEX = ‘00,00,00,00,00,01,00,10,00,00,00,01,00,00,00,01,10,00,00,01,00,00,00,01,00,00,00,01,00,04,00,34,8c,c7,73,37,28,9c,e2,0e,7d,b7,0c,ec,40,d9,fd,27,52,b0,76,11,33,e4,22,e3,ea,1b,d1,86,37,54,5a,6c,af,bd,51,bb,0d,4c,d9,ca,ec,e4,6b,c5,f9,02,ef,21,61,a1,06,17,3c,d9,58,44’
    $ADataHexified = $ADataValueHEX.Split(‘,’) | % { ‘0x$_’}
    $ADataValueBinary = ([byte[]]$ADataHexified)

    # Add registry values for ALL existing and future users
    [scriptblock]$HKCURegistrySettings = {
    Set-RegistryKey -Key $RegPath -Name ‘AData’-Value $ADataValueBinary -Type Binary -SID $UserProfile.SID
    }
    Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings

    • This reply was modified 1 year, 3 months ago by  Aldin. Reason: The formatting was screwed again by the forum

You must be logged in to reply to this topic.