Forum Discussion
NThoman
Jul 10, 2024Iron Contributor
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 col...
sdtslmn
Jul 25, 2024Brass Contributor
hope the following example helps if you need help please ping me
$GoButton.Add_Click({
foreach ($item in $JobQue.Items) {
if ($item.Checked) { # Process only if the item is checked
$time = $item.SubItems[0].Text
$sourceServer = $item.SubItems[1].Text
$sourceDB = $item.SubItems[2].Text
$destServer = $item.SubItems[3].Text
$destDB = $item.SubItems[4].Text
$status = $item.SubItems[5].Text # Assuming you have 6 columns
Write-Host "Starting Refresh $time - $sourceServer/$sourceDB to $destServer/$destDB"
My-Task -SourceServer $sourceServer -DestServer $destServer # Pass values to your function
}
}
})