title: Powershell get-childitem needs a lot of memory
body: <p>My question is pretty much the same as the one posted on metafilter.</p>
  
  <p>I need to use a PowerShell script to scan through a large amount of files. The issue is that it seems that the "Get-ChildItem" function insists on shoving the whole folder and file structure in memory. Since the drive has over a million files in over 30,000 folders, the script needs a lot of memory.</p>
  
  <p><a href="http://ask.metafilter.com/134940/PowerShell-recursive-processing-of-all-files-and-folders-without-OutOfMemory-exception" rel="nofollow">http://ask.metafilter.com/134940/PowerShell-recursive-processing-of-all-files-and-folders-without-OutOfMemory-exception</a></p>
  
  <p>All what I need is the name, size and location of the files.</p>
  
  <p>What I do since now is: </p>
  
  <pre><code>$filesToIndex = Get-ChildItem -Path $path -Recurse | Where-Object { !$_.PSIsContainer }
  </code></pre>
  
  <p>It works but I don't want to punish my memory :-)</p>
  
  <p>Best regards,
  greenhoorn</p>