Output of the Listbox

by chrisuk11 at 2013-01-30 12:54:07

I am using Sapeien Powershell to created a form. I am trying to populate a listbox with processes. This works to a degree however instead of just listing the name, every process shows as - @{name=chrome.exe}

I only want it to show the process name, example chrome or chrome.exe.

Code used -

$Processes = gwmi win32_Process -ComputerName pc1| sort DisplayName | select-object -Property name

foreach ($processname in $Processes)
{

$listbox1.Items.add($processname)


Any help would be appreciated

Thanks
by ArtB0514 at 2013-01-30 13:11:12
Try this:
$Processes = gwmi win32_Process -ComputerName pc1| sort DisplayName | select-object -ExpandProperty name
Or this:
$listbox1.Items.add($processname.name)
BUT NOT BOTH.