title: Loop stops prematurely
body: <p>I am writing an application that looks through a directory tree and reports if a folder is inactive based on last write time and read only attribute.</p>
  
  <p>However my loop stops after like 7 iterations even though there are thousands of folders.</p>
  
  <p>My code looks like:</p>
  
  <pre><code>function FolderInactive{
      Param([string]$Path)
      $date = (Get-Date).AddDays(-365)
      $anyReadOnly = $false
      Get-ChildItem $Path -File -ErrorAction SilentlyContinue | ForEach-Object {
          if($_.LastWriteTime -ge $date){
              $false
              continue
  
          }
          if($_.IsReadOnly -eq $false){
              $anyReadOnly = $true
          }
      }
      $anyReadOnly
  }
  
  Get-ChildItem "some drive" -Recurse | where {$_.PSIsContainer} | Foreach-Object {
      Write-Host $_.FullName
      FolderInactive($_.FullName)
  
  }
  </code></pre>
  
  <p>If I comment out the <code>FolderInactive</code> function call in the Foreach loop it prints all the folders, but with the function call it stops after a few iterations. What is happening?</p>