Is there a way to dynamically add click events to variables in powershell/winforms
I work in a small air-gapped network of windows machines and have been building a powershell script that queries my wsus for machine information, which I use for certain admin tasks later in the script. I’ve been building a gui for it using winforms in powershell, and am stuck on one logic puzzle to get this to dynamically change as my environment changes. The script starts by creating groupboxes based on the groups in my wsus, and then fills in the machines as they match their perspective groups. The issue I’m having is that I want to add a select all button to each groupbox that selects all items in the groupbox for that select-all checkbox. I can do this if I manually index through the list, but this breaks the ability for my script to be dynamic and grow or shrink based on groups that come and go from my wsus. I think the issue lies in the click event always referencing the last index it loops through.