-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description of acceptable values for PropertyType parameter is inaccurate and/or confusing #8739
Description
Prerequisites
- Write a descriptive title.
- Search the existing issues.
- I am reporting the documentation problem for version of PowerShell I am using.
Version
5.1, 7.1
Link to affected document
Description of the documentation error
Summary
Description of acceptable values for PropertyType parameter is inaccurate and/or confusing
Observed documentation
The description for the acceptable values of the PropertyType parameter of the New-ItemProperty cmdlet is as follows:
-PropertyType
Specifies the type of property that this cmdlet adds. The acceptable values for this parameter are:
String: Specifies a null-terminated string. Equivalent to REG_SZ.
ExpandString: Specifies a null-terminated string that contains unexpanded references to environment variables that are expanded when the value is retrieved. Equivalent to REG_EXPAND_SZ.
Binary: Specifies binary data in any form. Equivalent to REG_BINARY.
DWord: Specifies a 32-bit binary number. Equivalent to REG_DWORD.
MultiString: Specifies an array of null-terminated strings terminated by two null characters. Equivalent to REG_MULTI_SZ.
Qword: Specifies a 64-bit binary number. Equivalent to REG_QWORD.
Unknown: Indicates an unsupported registry data type, such as REG_RESOURCE_LIST.
Each value states Equivalent to <name of registry datatype>. This leads me to believe that, for example, the string "REG_BINARY" can be substituted for the string "Binary", and will have the same effect when supplied as the argument for this parameter.
Observed behavior
However this is not the case. In both 5.1 and 7.1, supplying "REG_BINARY" results in the following error:
New-ItemProperty : Could not bind parameter 'Type'. Could not convert "REG_BINARY" to "Microsoft.Win32.RegistryValueKind".
The possible enumeration values are "String, ExpandString, Binary, DWord, MultiString, QWord, Unknown".
I have not tested the other values, but the error description leads me to believe they would behave no differently.
Expected behavior / suggested fix
Either of:
A), the cmdlet accepts e.g. "REG_BINARY" as an equivalent value to "Binary",
or B) the documentation clearly indicates that strings such as "REG_BINARY" are NOT acceptable values for this parameter, and that the list of acceptable values are strings which REPRESENT (but are not "EQUIVALENT TO") their respective registry-parlance datatype counterparts.
Environment tested
Windows 10 Enterprise 64-bit 20H2 - 21H2
PowerShell console v5.1 and v7.1
I have no reason to believe this isn't also present in other versions of PowerShell, but I've only tested 5.1 and 7.1.