Output of the Listbox

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 5 years, 8 months ago.

  • Author
    Posts
  • #5487

    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.

You must be logged in to reply to this topic.