Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xRegistry: Unable to create binary registry value with data '0x00' #276

Closed
Amedama96 opened this issue Nov 19, 2016 · 1 comment
Closed
Labels
bug The issue is a bug.

Comments

@Amedama96
Copy link

Description

I want to create binary registry value with data '0x00', but xRegistry resource set none value.

Detail

I want to create binary reg value with data zero
zero

For that, write and exec psdsc configuration like...

xRegistry Zero_RegBinary
{
    Ensure = "Present"
    Key = "HKEY_LOCAL_MACHINE\SYSTEM\Tests"
    ValueName = "TestValue"
    ValueData = "0x00"    # same result if you set ValueData="0", 
    ValueType = "Binary"
}

Then, sadly, xRegistry resource create a reg value that has 'zero-length binary value'
none

I confirmed the issue also have the In-box Regisrtry resource in Windows 10 1607.

How to fix

I've discovered the issue caused by this code.

$val = $Data[0].TrimStart('0x')

Apparently the code is intended to remove the first '0x' of $Data[0].
but if $Data[0] = '0' or '0x00', empty value is set in $val.
Perhaps this is undesired behavior.

I would like to propose to modify the code like...

if($Data[0].StartsWith('0x')) {
   $val = $Data[0].Substring(2)
}
else {
   $val = $Data[0]
}

It's a little redundant, but I think it is easy to understand and behave properly.

@kwirkykat kwirkykat added the bug The issue is a bug. label Nov 21, 2016
Amedama96 pushed a commit to Amedama96/xPSDesiredStateConfiguration that referenced this issue Nov 27, 2016
Amedama96 pushed a commit to Amedama96/xPSDesiredStateConfiguration that referenced this issue Nov 27, 2016
Amedama96 added a commit to Amedama96/xPSDesiredStateConfiguration that referenced this issue Nov 27, 2016
@kwirkykat kwirkykat self-assigned this Nov 29, 2016
@Amedama96
Copy link
Author

This issue fixed and merged #299 by @kwirkykat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants