Get-ChildItem returns a value I'm not interested in

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Stian Myhre Stian Myhre 2 years, 4 months ago.

  • Author
  • #22184
    Profile photo of Stian Myhre
    Stian Myhre

    Hi all!

    I'm quite stuck here, trying to get Powershell to return value "Name" from registry. So far, so good.

    gci $registrypath | ? {$_.Name -like "*Google*"}
        Hive: HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles
    SKC  VC Name                           Property                                                                                        
    ---  -- ----                           --------                                                                                        
     10   0 - Goo... {}                                                                                              

    On the other hand, if I'm trying to get the "Name" property from registry, I'm getting the full path to the registry value, and that's not what I want!

    (gci $registrypath | ? {$_.Name -like "*Google*"}).Name
    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\ - Google Apps

    All I want is this value: – Google Apps

    What in the #### am I doing wrong here?

  • #22191
    Profile photo of Tim Pringle
    Tim Pringle

    Hey Stian,

    Try this :

    (gci $registrypath | ? {$_.Name -like "*Google*"}).PSChildName
  • #22212
    Profile photo of Stian Myhre
    Stian Myhre

    Great, thanks! Thanks to you, I got introduced to the gm cmdlet 😀

You must be logged in to reply to this topic.