title: How to use powershell to search remote servers for folders
body: <p>I am trying to use powershell to search multiple remote servers with multiple logical disks for certain folders and want to get the folder path as output. My script is below, its working but it keeps on giving me results from one logical disk only.</p>
  
  <p>for example my server has 5 logical disks but my script keeps on searching C:\ for the folder Tools, and never moves forward to searching other logical disks</p>
  
  <pre><code>$Servers= @( "Server01" )
  foreach ($Server in $Servers) {
      gwmi -ComputerName $Server Win32_LogicalDisk | 
          where {$.DriveType -eq '3'} | 
          select-object DeviceID | 
          ForEach {
              Get-ChildItem ($.DeviceID + "\") -Recurse -ErrorAction SilentlyContinue
          } | Where-Object { ($.PSIsContainer -eq $true) -and ( $.Name -eq "Tools")} | 
          Select name, FullName 
  }
  </code></pre>