Skip to content

Issue when a Property Key has no value set #1

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

Open
Rapidhands opened this issue Jun 2, 2022 · 2 comments
Open

Issue when a Property Key has no value set #1

Rapidhands opened this issue Jun 2, 2022 · 2 comments
Assignees
Labels
backlog Issue is in queue to be worked on or analyzed

Comments

@Rapidhands
Copy link

Rapidhands commented Jun 2, 2022

Hi Daniele,
I've discover your function, and I've tested it. Let me show the error I have :

Get-Item @paramGetItem
    Hive: HKEY_CLASSES_ROOT

Name                           Property                                                                                                                                  
----                           --------                                                                                                                                  
search-ms                      (default)        : Windows Search Protocol                                                                                                
                               FriendlyTypeName : @C:\WINDOWS\explorer.exe,-6010                                                                                         
                               URL Protocol     :           

As you can see, the Property URL Protocol have no value set. Then, I have this error :

Exception lors de l'appel de « GetValueKind » avec « 1 » argument(s) : « La clé de Registre spécifiée n'existe pas. »
Au caractère Ligne:121 : 25
+                         [void]($returnData.Add([pscustomobject]@{
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

However the function returns the other parameters and their values.

Path         : HKEY_CLASSES_ROOT\search-ms
Name         : FriendlyTypeName
Value        : @%SystemRoot%\explorer.exe,-6010
Type         : ExpandString
Computername : LAPTOP-xxxx

Path         : HKEY_CLASSES_ROOT\search-ms
Name         : URL Protocol
Value        : 
Type         : String
Computername : LAPTOP-xxxx

I'm thinking you must add a test

# Append data to return array

                        if ($Null -eq $regItem.GetValueKind($property) ) { $Type = ""}
                        Else { $Type = $regItem.GetValueKind($property)}
                                               
                        [void]($returnData.Add([pscustomobject]@{
                                    'Path'  = $regItem
                                    'Name'  = $property
                                    'Value' = $regItem.GetValue($property, $null, 'DoNotExpandEnvironmentNames')
                                    'Type'  = $Type
                                    'Computername' = $env:computername
                                }))

But i've an error with the (default) parameter (no value, no type)

Exception lors de l'appel de « GetValueKind » avec « 1 » argument(s) : « La clé de Registre spécifiée n'existe pas. »
Au caractère Ligne:121 : 29
+ ...                if ($Null -eq $regItem.GetValueKind($property) ) { $Ty ...
+                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

But the display is OK

Path         : HKEY_CLASSES_ROOT\search-ms
Name         : (default)
Value        : 
Type         : 
Computername : LAPTOP-xxxx

Path         : HKEY_CLASSES_ROOT\search-ms
Name         : FriendlyTypeName
Value        : @%SystemRoot%\explorer.exe,-6010
Type         : ExpandString
Computername : LAPTOP-xxxx

Path         : HKEY_CLASSES_ROOT\search-ms
Name         : URL Protocol
Value        : 
Type         : String
Computername : LAPTOP-xxxx
@Rapidhands
Copy link
Author

Display is OK but export to a file is KO (cause the previous error)

@PsCustomObject
Copy link
Owner

Thanks for reporting this, please be patient as it is a really busy period and can take me a bit to react to look into this.

I am on the phone and can't see if you already did, but would you mind telling me the full key that is throwing the error? Just to have a reference on my dev machine without having to look for a key with the same characteristics.

@PsCustomObject PsCustomObject self-assigned this Jul 27, 2024
@PsCustomObject PsCustomObject added the backlog Issue is in queue to be worked on or analyzed label Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issue is in queue to be worked on or analyzed
Projects
None yet
Development

No branches or pull requests

2 participants