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

Registry values of type REG_RESOURCE_REQUIREMENTS_LIST are returned as NULL #24626

Open
5 tasks done
wisemoth opened this issue Nov 29, 2024 · 9 comments
Open
5 tasks done
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

Comments

@wisemoth
Copy link

Prerequisites

Steps to reproduce

Using Get-ItemPropertyValue on pwsh 7.5.0 rc1 on Windows 10 22h2 to fetch a registry key that happens to contain some values of type REG_RESOURCE_REQUIREMENTS_LIST 'successfully' returns the values of those property, but they are (silently) NULL.

reg query for the same key/value succeeds.

Expected behavior

(In Administrator terminal)

PS> Get-ItemPropertyValue hklm:\SYSTEM\ControlSet001\Control\Arbiters\ReservedResources -Name BrokenVideo | should -not -BeNullOrEmpty
PS> (success)

Actual behavior

(In Administrator terminal)

PS> Get-ItemPropertyValue hklm:\SYSTEM\ControlSet001\Control\Arbiters\ReservedResources -Name BrokenVideo | should -not -BeNullOrEmpty
InvalidResult:
Line |
   1 | get-itempropertyvalue hklm:\SYSTEM\ControlSet001\Control\Arbiters\ReservedResources -Name BrokenVideo | should -not -BeNullOrEmpty
     | Expected a value, but got $null or empty.

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.0-rc.1
PSEdition                      Core
GitCommitId                    7.5.0-rc.1
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

image

image

@wisemoth wisemoth added the Needs-Triage The issue is new and needs to be triaged by a work group. label Nov 29, 2024
@wisemoth
Copy link
Author

(though I now see reg states an incorrect valuetype in its output...)

@iSazonov
Copy link
Collaborator

The registry type is described in drivers docs. It is too specific to have in pwsh.

Nevertheless, here is a list types supported in .Net Runtime. There are more types than pwsh supports: REG_DWORD_LITTLE_ENDIAN, REG_DWORD_BIG_ENDIAN, REG_LINK.
We should add support for them especially since pwsh is now running on Arm.

@iSazonov iSazonov added WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc. Issue-Enhancement the issue is more of a feature request than a bug labels Nov 29, 2024
@wisemoth
Copy link
Author

wisemoth commented Nov 29, 2024 via email

@mklement0
Copy link
Contributor

Thanks, @iSazonov - makes sense to align what registry value types PowerShell supports with what .NET supports.

Separately, however, trying to use any unsupported type should result in an error rather than in quiet failure (and therefore no output).

@iSazonov
Copy link
Collaborator

Separately, however, trying to use any unsupported type should result in an error rather than in quiet failure (and therefore no output).

I agree it could be a non-termonating error, but we silently ignore unknown registry values for years so WG should weight the breaking change.

@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Dec 2, 2024

The .NET docs seem to be incomplete on the types not supported, but they do indicate unsupported types return null (not able to deep link, scroll down to notes). Looking at the code, there are specific types it supports and anything else null is returned.

For PowerShell, it looks like we COULD use GetValueKind() and if it's not in the known supported list (which would have to be maintained if .NET API changes) we return a warning or error. As noted, the current behavior is consistent with 5.1, so it would be a breaking change if anyone is relying on it to return $null instead of an error.

So the most I think can be done is return a warning, but I know users tend to hate those popping up when they didn't used to. So maybe this is a doc issue.

@iSazonov
Copy link
Collaborator

iSazonov commented Dec 3, 2024

The types are very specific - they are only for drivers. It's unbelievable that someone would write scripts to access such keys - it just doesn't make sense. So this change (non-terminating error) would be formal breaking change.

@wisemoth
Copy link
Author

wisemoth commented Dec 3, 2024

You can't assume anything about what people might want to use Powershell for. If you do, then large documentation changes would be needed to somehow convey "appropriate use".

Trivial example: comparison of "driver" registry key values between two machines is completely legitimate use of Powershell.

@wisemoth
Copy link
Author

wisemoth commented Dec 3, 2024

Problem with making it only a docs issue is it weakens the use of Powershell.

At runtime I still won't know the state of the registry, and I could NEVER know - no way to opt-in to even detect unsupported types

It seems a really rather strong appeal to compatibility (with a reduction in the utility of an amazing tool) that new warnings could never be countenanced in any version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine-Providers built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Projects
None yet
Development

No branches or pull requests

4 participants