title: Powershell, look through all drives
body: <p>I'm new to Powershell and I've tried finding a solution to my problem online but I can't seem to find one. Basically I need to write something that will let powershell look through all drives and directories to find the following:</p>
  
  <p>total number of files (exclude folders), largest file size, average file size, total file size</p>
  
  <p>Here's what I've written so far:</p>
  
  <pre><code>$source = "get-psdrive"
  
  #attempt at looking through all drives/directories which didn't work
  foreach($a in $source) {
  
      #counts files in given directory
      Get-ChildItem -Recurse -File -ErrorAction SilentlyContinue -Force |
          Measure-Object |
          ForEach-Object { $_.Count }
  
      #select largest file in given directory
      Get-ChildItem -Recurse -File -ErrorAction SilentlyContinue -Force |
          Sort-Object Length -Descending |
          Select-Object -First 1
  
      #get average file size in a given directory
      Get-ChildItem -Recurse -File -ErrorAction SilentlyContinue -Force |
          Measure-Object -Property Length -Average
  
      #sum of file sizes in given directory
      (Get-ChildItem -Recurse -File -ErrorAction SilentlyContinue -Force |
          Measure-Object -Sum Length).Sum
  }
  </code></pre>
  
  <p>The issue is that it only looks in the C drive. I don't know if there's a way to look through my computer instead of specific drives but I couldn't seem to find a way. Any help is appreciated.</p>