Populate checked listbox
- DerekSchaulandMVP
- Posts: 27
- Last visit: Tue Dec 15, 2020 10:53 am
Populate checked listbox
I have a checked listbox being populated by the following code $grouplist = (get-adgroup -filter * | select-object Name) foreach($group in $grouplist){ $groups.items.add($group)} the box populates but returns @{Name=GroupName} for each line. All the contents are correct. How can I clean up the display to just show the group name?
Populate checked listbox
Try this:$grouplist = (get-adgroup -filter * )foreach($group in $grouplist){ $groups.items.add($group.Name)} David
davidc2012-04-19 14:09:17
davidc2012-04-19 14:09:17
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- DerekSchaulandMVP
- Posts: 27
- Last visit: Tue Dec 15, 2020 10:53 am
- DerekSchaulandMVP
- Posts: 27
- Last visit: Tue Dec 15, 2020 10:53 am
Populate checked listbox
Hmmm ok.. the plot thickens. Can I get more than one property to display in the list box? Name and GroupCategory?
Populate checked listbox
You can always create a string that contains the information you want.For example: $groups.items.add("$($group.Name): $($group.GroupCategory)") The ListBox is very similar to the ComboBox. I recommend reading our Spotlight article on the ComboBox. David
davidc2012-04-19 15:45:02
davidc2012-04-19 15:45:02
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
- DerekSchaulandMVP
- Posts: 27
- Last visit: Tue Dec 15, 2020 10:53 am
Populate checked listbox
David - thanks again.. Powershell is one of those things that makes sense until you try it, looks like Im all set