Adding Key - Value pairs to ListView powershell

Viewed 27

I have a Hash table with a key value pair and I need to get this information inside a list view.

Here is my hash table.

Name                           Value                                                                                                                                                 
----                           -----                                                                                                                                                 
sonic_sis                      {currentVersion, remoteVersion}                                                                                                                                                                                                                                            
sonic_interceptor              {currentVersion, remoteVersion}     

Inside the currentVersion and remoteVersion there are values also.

I need the list view to break down like this < sonic_sis < currentVersion(what ever value is in that) remoteVersion(whatever value is in this.)

It is not working for me so far.

This is how I am trying to do it.

$listview1.Items.Clear()
    Write-Host "Items cleared..."
    Get-LocalRemoteHash
    Write-Host "Get-LocalRemoteHash ran."
    Select-Object Name, currentVersion, remoteVersion
    ForEach($Item in $hash) {
        $data = [System.Windows.Forms.ListViewItem]::new()
        $data.Text = $hash
        $data.SubItems.Add($hash.currentVersion)
        $data.SubItems.Add($hash.remoteVersion)
        $listview1.Items.Add($data)
        Write-Host "Data put in list"
    }
    Write-Host "End"
0 Answers
Related