Read Item and Subs from System.Windows.Forms.ListView

Iron Contributor

I am building a UI around a PowerShell script to make it more user friendly. I am have ListView that holds a Queue of Jobs that need to be run. How do I loop through it and get the values of each column so I can pass the properties as variables to another process\function?


$JobQue = New-Object System.Windows.Forms.ListView
$JobQue.Text = 'Queued Jobs'
#$JobQue.Font = $DefaultFont
$JobQue.Location = '435,140'
$JobQue.Size = '730,235'
$JobQue.View = "Details"
$JobQue.Sorting = "Ascending"
$JobQue.CheckBoxes     = $true
$JobQue.MultiSelect    = $true
$JobQue.FullRowSelect  = $true
[VOID]$JobQue.Columns.Add('Time', 170)
[VOID]$JobQue.Columns.Add('Source Server',115)
[VOID]$JobQue.Columns.Add('Source DB',115)
[VOID]$JobQue.Columns.Add('Dest Server',115)
[VOID]$JobQue.Columns.Add('Dest DB',115)


That is the snippet of the JobQue List.  Whole PS script is quite large. Trying to do something like this:


    ForEach($Task in $JobQue.Items){
        Write-Host "Starting Refresh $Task"
        My-Task($Task.['Source Server'],$Task.['Dest Server'])
0 Replies