title: Powershell ForEach-Object column variables
body: <p>Kind of have a strange problem. I have a large JSON file that needs to be processed. Based on another question I need to stream the file since it will otherwise gets me problems because of memory: <a href="https://stackoverflow.com/questions/67368729/json-powershell-memory-issue">JSON Powershell memory issue</a></p>
  <p>What I have is this:</p>
  <pre><code>get-content -Path largefile.json | ForEach-Object {
  $row = $_ = $_.TrimStart('[').TrimEnd(']')
  if ($_) { $_ | Out-String | ConvertFrom-Json }
  New-Item -Path $($Row.Id).txt
  Set-Content -Path $($Row.Id).txt -Value ($row.Body)
  }
  </code></pre>
  <p>I can easily do $row to publish the last processed row in the Largefile.json. I want to create a file with the name of the Id in the row that is currently processed and add the body column to the file. But when I want to show a specific column using $row.Id, unfortunately this shows up empty.</p>
  <p>The structure of the Largefile.json is as followed:</p>
  <pre><code>[{&quot;Id&quot;:&quot;1&quot;,&quot;ParentId&quot;:&quot;parent&quot;,&quot;Name&quot;:&quot;filename&quot;,&quot;OwnerId&quot;:&quot;owner&quot;,&quot;CreatedDate&quot;:&quot;date&quot;,&quot;Body&quot;:&quot;data1&quot;}
  {&quot;Id&quot;:&quot;2&quot;,&quot;ParentId&quot;:&quot;parent&quot;,&quot;Name&quot;:&quot;filename&quot;,&quot;OwnerId&quot;:&quot;owner&quot;,&quot;CreatedDate&quot;:&quot;date&quot;,&quot;Body&quot;:&quot;data2&quot;}
  {&quot;Id&quot;:&quot;3&quot;,&quot;ParentId&quot;:&quot;parent&quot;,&quot;Name&quot;:&quot;filename&quot;,&quot;OwnerId&quot;:&quot;owner&quot;,&quot;CreatedDate&quot;:&quot;date&quot;,&quot;Body&quot;:&quot;data3&quot;}
  {&quot;Id&quot;:&quot;4&quot;,&quot;ParentId&quot;:&quot;parent&quot;,&quot;Name&quot;:&quot;filename&quot;,&quot;OwnerId&quot;:&quot;owner&quot;,&quot;CreatedDate&quot;:&quot;date&quot;,&quot;Body&quot;:&quot;data4&quot;}
  {&quot;Id&quot;:&quot;5&quot;,&quot;ParentId&quot;:&quot;parent&quot;,&quot;Name&quot;:&quot;filename&quot;,&quot;OwnerId&quot;:&quot;owner&quot;,&quot;CreatedDate&quot;:&quot;date&quot;,&quot;Body&quot;:&quot;data5&quot;}
  ]
  </code></pre>
  <p>The end result should be that I have 5 files:</p>
  <ul>
  <li><p>1.txt - Value inside the file should be: data1</p>
  </li>
  <li><p>2.txt - Value inside the file should be: data2</p>
  </li>
  <li><p>3.txt - Value inside the file should be: data3</p>
  </li>
  <li><p>4.txt - Value inside the file should be: data4</p>
  </li>
  <li><p>5.txt - Value inside the file should be: data5</p>
  </li>
  </ul>
  <p>I use Powershell 7.1.3</p>
  <p>Is there any way that I can use $row.Id and $row.ParentId just like a regular ForEach would do?</p>
  <p>thanks for your help.</p>