title: Struggling to export PowerShell job information to excel
body: <p>I have a PowerShell script that is running a web request as part of a job. With the script block that is run by the job I am logging the Endpoint Uri and the response time. and then after all the jobs are finished but before I remove the jobs I am trying to export the result into excel. </p>
  
  <p><strong>PS Verion:</strong></p>
  
  <pre><code>Major  Minor  Build  Revision
  -----  -----  -----  --------
  5      1      17763  503     
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>$Code = {
      Param(
          [array]$Domain,
          [array]$Services,
          [array]$TestData,
          [string]$Path
      )
  
      $Log = @()
  
      ## Get Random School ##
      $Random = Get-Random -InputObject $TestData -Count 1
  
      ## Get Random Service ##
      $RandService = Get-Random -InputObject $Services
  
      ## Get Random Endpoint ## 
      $ServiceEndpoints = Get-Content "$Path\Service.Endpoints.json" | Out-String | ConvertFrom-Json
      $GatewayEndpoints = $ServiceEndpoints.Services.$RandService.Gateway
      $RandomEndpoint = Get-Random -InputObject $GatewayEndpoints
  
      $Headers = @{
          "Authorization" = "Bearer" + ' ' + $Random.Token
      }
  
      $Uri = 'https://' + $Domain + $RandomEndpoint
  
      Try {
          $TimeTaken = Measure-Command -Expression {
              $JsonResponse = Invoke-WebRequest -Uri $Uri -Headers $Headers -ContentType 'application/json' -Method Get -UseBasicParsing
          }
      }
      Catch {
      }
  
      $ResponseTime = [Math]::Round($TimeTaken.TotalMilliseconds, 1) 
  
      $LogItem = New-Object PSObject
      $LogItem | Add-Member -type NoteProperty -Name 'Endpoint' -Value $Uri
      $LogItem | Add-Member -type NoteProperty -Name 'Time' -Value $ResponseTime
      $Log += $LogItem 
  
      Write-Host $Log
  }
  
  #Remove all jobs
  Get-Job | Remove-Job
  
  #Start the jobs. Max 4 jobs running simultaneously.
  foreach($Row in $TestData){
      While ($(Get-Job -state running).count -ge $MaxThreads){
          Start-Sleep -Milliseconds 3
      }
      Start-Job -Scriptblock $Code -ArgumentList $Domain, $Services, $TestData, $Path
  }
  
  #Wait for all jobs to finish.
  While ($(Get-Job -State Running).count -gt 0) {
      start-sleep 1
  }
  
  $Log | Export-XLSX -Path .\Test.Results\Performance\Performance.Test.Log.xlsx -ClearSheet
  
  #Get information from each job.
  foreach($Job in Get-Job) {
      $Info = Receive-Job -Id ($Job.Id)
  }
  
  #Remove all jobs created.
  Get-Job | Remove-Job
  </code></pre>
  
  <p>I cannot seem to get the endpoint uri and the response time out of the script block. When I try to export the <code>$Log</code>, all that happens is it creates an empty excel file. </p>
  
  <p><strong>Write-Host $Log</strong></p>
  
  <pre><code>@{Endpoint=https://domain/customer/v1/years/2019/marks; Time=1233.3}
  @{Endpoint=https://domain/customer/v1/years/2019/marks; Time=2131.7}
  </code></pre>