I'm trying to check an item into a ListBox after clicking a Radio Button, but no success. Specifically, I'm trying to check a Active Directory Group already listed.
I made this piece of script:
$Action = foreach ($SecurityGroup in $ADSecurityGroup)
{
$SecurityGroup.Name -eq "AD Example"
{
[void] $ADGroups.Items.Add($SecurityGroup.Name, $True)
}
}
And after added to Add_Click of Raddio Button:
$RadioButton.Add_Click($Action)
Someone could help me?
I achieved what I was looking for with this:
$RadioButton.Add_Click({
for ($i = 0; $i -lt $ADGroups.Items.Count; $i++)
{
If ($ADGroups.Items[$i] -match 'AD Group that I wanted to change status')
{
$ADGroups.SetItemChecked($i, $true)
}
}
})
I publish it in case it is useful to someone.
Thanks a lot!