title: Running multiple scriptblocks at the same time with Start-Job (instead of looping)
body: <p><strong>Hi all!</strong></p>
  
  <p>I've been looking for a way to make my script more efficient and I've come to the conclusion (with help from the nice people here on StackOverflow) that Start-Job is the way to go.</p>
  
  <p>I have the following foreach-loop that I would like to run simultanously on all the servers in $servers. I have problems understanding how I actually collect the information returned from Receive-Job and add to $serverlist.</p>
  
  <p><em>PS: I know that I am far away from getting this nailed down, but I would really appreciate some help starting out as I am quite stumped on how Start-Job and Receive-Job works..</em></p>
  
  <pre><code># List 4 servers (for testing)
  $servers = Get-QADComputer -sizelimit 4 -WarningAction SilentlyContinue -OSName *server*,*hyper*
  
  # Create list
  $serverlistlist = @()
  
  # Loop servers
  foreach($server in $servers) {
  
      # Fetch IP
      $ipaddress = [System.Net.Dns]::GetHostAddresses($Server.name)| select-object IPAddressToString -expandproperty IPAddressToString
  
      # Gather OSName through WMI
      $OSName = (Get-WmiObject Win32_OperatingSystem -ComputerName $server.name ).caption
  
      # Ping the server
      if (Test-Connection -ComputerName $server.name -count 1 -Quiet ) {
          $reachable = "Yes"
      }
  
      # Save info about server
      $serverInfo = New-Object -TypeName PSObject -Property @{
          SystemName = ($server.name).ToLower()
          IPAddress = $IPAddress
          OSName = $OSName
      }
      $serverlist += $serverinfo | Select-Object SystemName,IPAddress,OSName
  }
  </code></pre>
  
  <p><strong>Notes</strong></p>
  
  <ul>
  <li>I am outputting $serverlist to a csv-file at the end of the script</li>
  <li>I list aprox 500 servers in my full script</li>
  </ul>