title: PowerShell: ConvertFrom-Json to export multiple objects to csv
body: <p>As you probably understand from the title, I'm new to PowerShell, having a hard time even trying to describe my question. So please forgive my terminology.</p>
  
  <p><strong>Scenario</strong></p>
  
  <p>I am using PowerShell to query the audit log of Office 365. The cmdlet <code>Search-UnifiedAuditLog</code> returns "multiple sets of objects"(?), one of which has an array of other objects(?). The output is JSON if I got this right.</p>
  
  <p>Here is an example of what is returned (I will call it one "Set of Objects"):</p>
  
  <pre><code>RunspaceId   : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  RecordType   : AzureActiveDirectoryStsLogon
  CreationDate : 21/02/2017 12:05:23
  UserIds      : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  Operations   : UserLoggedIn
  AuditData    : {"CreationTime":"2017-02-21T12:05:23","Id":"{"ID":"00000000000000000","Type":3}],"ActorContextId":"xxxxxxxxxxxxxxxxxxxxxxxxx","ActorIpAddress":"xxxxxxxxxxxxx","InterSystemsId":"xxxxxxxxxxxxxxxxx","IntraSystemId":"000000000000-000000-000","Target":[{"ID":"00-0000-0000-c000-000000000000","Type":0}],"TargetContextId":"xxxxxxxxxxxxxxxxxx","ApplicationId":"xxxxxxxxxxxxxxxxxxxxxxxxxx"}
  ResultIndex  : 1
  ResultCount  : 16
  Identity     : xxxxxxxxxxxxxxxxxxxxxxxxxxx
  IsValid      : True
  ObjectState  : Unchanged
  </code></pre>
  
  <p>Now, I want some of the content of the <code>AuditData</code> line exported to a csv (normally containing much more data than copied here). This works fine for one "set of objects" (like the one above). To do this I use:</p>
  
  <pre><code>$LogOutput = Search-UnifiedAuditLog -StartDate 2/20/2017 -EndDate 2/23/2017 -ResultSize 1
  $ConvertedOutput = ConvertFrom-Json -InputObject $LogOutput.AuditData
  $ConvertedOutput | Select-Object CreationTime,UserId,ClientIP | Export-Csv -Path "C:\users\some.user\desktop\users.csv
  </code></pre>
  
  <p><code>ResultSize</code> returns 1 instead of multiple "sets of objects". The <code>ConvertFrom-Json</code> does not work if I remove <code>ResultSize</code>.</p>
  
  <p><strong>So the question is:</strong></p>
  
  <p>Can I loop through <strong>all</strong> the "set of objects" and convert from json and have this exported line-by-line on a csv? Resulting in something like this:</p>
  
  <pre><code>UserId,Activity,UserIP
  this@user.com, loggedIn, 10.10.10.10
  that@user.org, accessedFile, 11.11.11.11
  </code></pre>
  
  <p>A pedagogic answer would be very, very much appreciated. Many thanks!</p>