CodeDump icon indicating copy to clipboard operation
CodeDump copied to clipboard

Issue when doing Binary with Set-RegistryValueForAllUsers

Open MazeGoh opened this issue 5 years ago • 1 comments

First of all, thanks for the super nice script you had created. For my cases I try to assign a binary key value of "080000000000000001000000020000000300000004000000050000000600000007000000" In the end, the it give me an error Set-ItemProperty : Cannot convert value "080000000000000001000000020000000300000004000000050000000600000007000000" to type "System.Byte[]". Error: "Cannot convert value "080000000000000001000000020000000300000004000000050000000600000007000000" to type "System.Byte". Error: "Value was either too large or too small for an unsigned byte."" At line:34 char:17

  • ... Set-ItemProperty -Path "HKU:$sid$($instance.Path)" -Nam ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : WriteError: (HKEY_USERS\S-1-...\Addin Menu IDs:String) [Set-ItemProperty], PSInvalidCastException
    • FullyQualifiedErrorId : System.Management.Automation.PSInvalidCastException,Microsoft.PowerShell.Commands.SetItemPropertyCommand

MazeGoh avatar Aug 10 '20 02:08 MazeGoh

I'm not sure if I had this issue resolve or not

I check some post and stated need to manually hexified the binary $regKeyValue = "08,00,00,00,00,00,00,00,01,00,00,00,02,00,00,00,03,00,00,00,04,00,00,00,05,00,00,00,06,00,00,00,07,00,00,00" $hexified = $regKeyValue.Split(',') | ForEach-Object { "0x$_"}

After I done it, the error doesn't come out anymore but in the stubpath the registry key was showing System.Byte[] instead of the actual value. I wonder where registry editor actually store those value at

MazeGoh avatar Aug 10 '20 10:08 MazeGoh