Read Item and Subs from System.Windows.Forms.ListView
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 processfunction?
$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)
[VOID]$JobQue.Columns.Add(‘Status’,90)
That is the snippet of the JobQue List. Whole PS script is quite large. Trying to do something like this:
$GoButton.Add_Click({
ForEach($Task in $JobQue.Items){
Write-Host “Starting Refresh $Task”
$Task.SubItems.Text
My-Task($Task.[‘Source Server’],$Task.[‘Dest Server’])
}
})
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 processfunction? $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)
[VOID]$JobQue.Columns.Add(‘Status’,90) That is the snippet of the JobQue List. Whole PS script is quite large. Trying to do something like this: $GoButton.Add_Click({
ForEach($Task in $JobQue.Items){
Write-Host “Starting Refresh $Task”
$Task.SubItems.Text
My-Task($Task.[‘Source Server’],$Task.[‘Dest Server’])
}
}) Read More