title: Sort folders according last modified date of subfolders
body: <p>I have a windows network share with over 1000 folders that also have subfolders.</p>
  
  <p>I want to delete the folders that have not been modified since a few years.</p>
  
  <p>When I sort in File Explorer after "date modified", it sorts the parent folders correctly.</p>
  
  <p>But changes in subfolders are not considered.</p>
  
  <p>I try to create a PowerShell script that sorts all folders on the network share considering the last write time in folder or subfolder.</p>
  
  <p>Unfortunately in the current state it lists only the latest modified folder over and over again.</p>
  
  <p>Example:</p>
  
  <pre><code>Get-ChildItem c:\tmp -Directory | ForEach-Object { Get-ChildItem -Directory -Recurse | Sort {$_.LastWriteTime} -Descending | Select {$_.FullName}, {$_.LastWriteTime} -First 1 }
  </code></pre>
  
  <p>Can someone help?</p>