title: Getting output from a Start-Job invocation
body: <p>I have the following code that works in that it creates multiple jobs and runs what's inside the scriptblock on all of the computers in the array (<code>$SMSMembers</code>).  The problem is that it doesn't give any sort of meaningful output back that I can use to determine if the code ran successfully or not.  I have tried about 100 different things that I have Googled but none of the solutions seemed to work for me.  This is the code I'm trying to run that I thought should work according to other posts I've seen on StackOverflow.</p>
  
  <pre><code>$SMSMembers = @("computer1","computer2","computer3")
  $output = @()
  foreach ($compName in $SMSMembers) {
      $scriptblock = {
          $file = {"test"}
          $filepath = "\\$using:compName\c$\scripts\NEWFILE.txt"
          $file | Out-File -FilePath $filepath
          Start-Sleep -Seconds 5
          Remove-Item $filepath
      }
      $output += Start-Job -ScriptBlock $scriptblock | Get-Job | Receive-Job
  }
  Get-Job | Wait-Job
  foreach ($item in $output) {
      Write-Host $item
  }
  </code></pre>
  
  <p>This script doesn't do much except copy a file to a remote computer and then delete it.  I would just like to get output if the job was successful or not. Like I said this code works like it should, I just don't get feedback.</p>
  
  <p>My end goal is to be able to send a command to an array of computers (<code>$SMSMembers</code>) and request the current user with this code and get the username input back:</p>
  
  <pre><code>$user = gwmi Win32_ComputerSystem -Comp $compName |
          select Username -ExpandProperty Username
  </code></pre>