title: Receive-Job missing data
body: <p>I have created a PowerShell script to dump some details from Office 365 into a csv. There are 120,000 accounts in the Azure AD. To speed up the process I have split the script up into 25 jobs.</p>
  
  <p>Everything works apart from the output for MFAState and Errors which return no data.</p>
  
  <p>My script previously without using jobs works perfectly. Any ideas why the data is not being returned by the job?</p>
  
  <pre><code>#### Editable Section #####
  $jobcount = 25                  # Set the maximum jobs
  $usersperbatch = 5000           # Users per batch
  $username = "user@example.com"  # MSOL Admin account
  
  #### Start Script #####
  
  # Get Credential and connect
  $cred = Get-Credential $username
  
  "Connecting to MSOnline"
  if (Get-Module MSOnline) {Import-Module MSOnline}
  
  Connect-MsolService -Credential $cred
  
  "Getting MSOL Accounts"
  $MSOLUsers = Get-MsolUser -All
  "Total Users: $($MSOLUsers.Count)"
  
  # Set counts
  $i = 0
  $j = $usersperbatch - 1
  $batch = 1
  
  while ($i -lt $MSOLUsers.count)
  {
  
      # Pause job creation if jobs equal $jobcount 
      $running = @(Get-Job | Where-Object {$_.State -eq 'Running'})
      if ($running.Count -ge $jobcount) {$running | Wait-Job -Any | Out-Null}
  
      # Create batch of users
      $userbatch = $MSOLUsers[$i..$j]
  
      # Create Scriptblock for job
      $sb = {
          # Import Arguments
          param ($cred, $MSOLUsers)
  
          # Connect to AAD
          Connect-MsolService -Credential $cred
  
          $Results = @()
  
          Foreach ($m in $MSOLUsers)
          {
  
              $Result = New-Object PSObject
  
              $Result | Add-Member -MemberType "NoteProperty" -Name DisplayName -Value $m.DisplayName
              $Result | Add-Member -MemberType "NoteProperty" -Name FirstName -Value $m.FirstName
              $Result | Add-Member -MemberType "NoteProperty" -Name LastName -Value $m.LastName
              $Result | Add-Member -MemberType "NoteProperty" -Name UserPrincipalName -Value $m.UserPrincipalName
              $Result | Add-Member -MemberType "NoteProperty" -Name WhenCreated -Value $m.WhenCreated   
              $Result | Add-Member -MemberType "NoteProperty" -Name GUID -Value $m.GUID
              $Result | Add-Member -MemberType "NoteProperty" -Name LastDirSyncTime -Value $m.LastDirSyncTime
              $Result | Add-Member -MemberType "NoteProperty" -Name StrongPWord -Value $m.StrongPasswordRequired
              $Result | Add-Member -MemberType "NoteProperty" -Name Disabled -Value $m.BlockCredential
              $Result | Add-Member -MemberType "NoteProperty" -Name MFAState -Value $m.StrongAuthenticationRequirements.State
              $Result | Add-Member -MemberType "NoteProperty" -Name IsLicensed -Value $m.IsLicensed
              $Result | Add-Member -MemberType "NoteProperty" -Name Valid -Value $m.ValidationStatus
              $Result | Add-Member -MemberType "NoteProperty" -Name Errors -Value $m.Errors.ErrorDetail.ObjectErrors.ErrorRecord.ErrorDescription
  
              $Results += $Result
  
          } # End Foreach
  
          $Results
  
      } # End Scriptblock
  
      # Create Job Name based on Range
      $jobname = "$i-$j"
  
      # Start job
      Start-Job -Name $jobname -ScriptBlock $sb -ArgumentList $cred, $userbatch
  
      # update counts
      $batch += 1
      $i = $j + 1
      $j += $usersperbatch
  
      if ($i -gt $MSOLUsers.count) {$i = $MSOLUsers.count}
      if ($j -gt $MSOLUsers.count) {$j = $MSOLUsers.count}
  
  } # End While
  
  # Get Results
  $Results = Get-Job | Receive-Job -Wait
  </code></pre>