Ardra Madhu
Ardra Madhu

Reputation: 167

recurse through powershell object

i am trying to browse through result i received from a command, Problem is when i access property i get only property name not corresponding path.

enter image description here

$com1 = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall*' | ? { $_ -match "Firefox" }

Command i tried to recurse:
$prop = $com1 | Select-Object  'Property' # Select only item property

then i get result without any mapping of property values.

result i get pasted below

Property                                        
--------                                               
{Comments, DisplayIcon, DisplayName, DisplayVersion...}

i expect to get value of comments and displayicon as i get in the image in the first time.

Upvotes: 3

Views: 518

Answers (2)

mklement0
mklement0

Reputation: 437823

To complement Mathias R. Jessen's helpful answer:

In PSv5+ you can use the Get-ItemPropertyValue cmdlet, which simplifies matters by retrieving the data (property value) directly:

$PropertyValue = $com1 | Get-ItemPropertyValue -Name Property

Alternatively, given that $com1 appears to have been retrieved with Get-Item from a registry-provider location and is therefore an instance of type [Microsoft.Win32.RegistryKey], you can call its .GetValue() method directly:

$com1.GetValue('Property')

Upvotes: 0

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174485

Use Get-ItemProperty to get the actual property values from registry keys:

$PropertyValue = ($com1 | Get-ItemProperty -Name "property").property

Upvotes: 4

Related Questions