title: How do I populate an array with get-process results in powershell
body: <p>I'm trying to write a PS1 script that:<br>
  1. takes a computer name and a process name<br>
  2. Shows you all PIDs and processes that match your search<br>
  3. Asks you what PID you want to kill. (I haven't included this part of the code)</p>
  
  <p>I need help on the $processInfo array. 
  I want to be able to look through each of the processes and show the name and ID. and then I'll know what PID to kill after that. </p>
  
  <p>So if I search "App*" how can I output to the format of:  </p>
  
  <pre><code>Process ID: 1000 Name: Apple
  Process ID: 2000 Name: Appster
  Process ID: 3000 Name: AppSample
  </code></pre>
  
  <p>Here's what I have so far</p>
  
  <pre><code># Look up a computer, and a process, and then 
  $computerName = Read-Host "Enter the FQDN of the target computer:"
  
  # Enter the name of the process you're looking for. Wildcard searching is asterix
  $processSearch = Read-Host "Enter the process name to look for:"
  
  # Create a process array with PID, Name, and Runpath
  $processInfo = (
      processID = get-process -ComputerName $computerName -Name $processSearch | select -expand ID,
      processName = get-process -ComputerName $computerName -Name $processSearch |select -expand Name,
      processPath = get-process -ComputerName $computerName -Name $processSearch |select -expand Path
  )
  
  # Display all of the processes and IDs that match your search
  foreach($id in $processInfo){
      write-host Process ID: $id.processID Name: $id.processName
  }
  </code></pre>