I am trying to setup a selection list using $Listbox.Items.Add but I do not want to use static data but rather content from Get-DistributionGroup and have not figured out how to add the content yet. I tried piping to text file but it adds spaces to the DG name which breaks the search.
$listBox.SelectionMode = "Multiextended"
$FullDL = Get-DistributionGroup -anr "x-a" | Format-Table Name
Get-content $FullDL | ForEach-Object {[void] $ListBox.Items.Add($_)}
$form.Controls.Add($listBox)
$form.Topmost = $True
$result = $form.ShowDialog()
Any help would be much appreciated.