Reputation: 629
I'm currently experimenting and trying to get this code:
$processnames = Get-Process | select name
foreach ($processname in $processnames)
{
[void]$AD_list_current.Items.Add($processnames)
}
to output in a listbox. It outputs as it is but for some reason it keeps displaying in the listbox as:
Does anyone know why this is?
It would be greatly apprechiated.
Thank you
Upvotes: 1
Views: 1535
Reputation: 126902
Here's a shorter way to add all process names:
$list.Items.AddRange( (Get-Process | select name) )
Upvotes: 3
Reputation: 65197
You are adding $processnames
instead of $processname
to your list.
That's an array.
As per Joey's comment, the default ToString()
method will show the type name, which is System.Object
.
Upvotes: 1