Hi!
I’m trying to create my firsts PowerShell GUI scripts…
I need to know how to add data to specific columns on a ListBox with MultiColumns property set.
My code is this for now:
$ListBox1 = New-Object System.Windows.Forms.ListBox
$ListBox1.Location = New-Object System.Drawing.Point(22,43)
$ListBox1.Size = New-Object System.Drawing.Size(410,410)
$ListBox1.AutoSize = $true
$ListBox1.MultiColumn = $true
$ListBox1.SelectionMode = "MultiExtended"
$ListBox1.ColumnWidth = 250
$Users = get-aduser -filter "name -like 'a*'" -Properties SamAccountName
foreach ($User in $Users){
$ListBox1.Items.Add($User.Name) | Out-Null
}
$form.Controls.Add($ListBox1)
But it only adds data to the first column, and I wanted to add the SamAccountName to the second column.
Something like this:
Name / SamAccountName
User Full Name / user.name
Second User Full Name / seconduser.name
Any ideas?