0

I’m trying to get all *.log files within mount point sub directories.

Command: [IO.Directory]::GetDirectories('e:\')

is showing me all directories; how do I search theses subdirectories for *.log files?

TRiG
  • 10,148
  • 7
  • 57
  • 107

1 Answers1

0
get-childItem e:\ -recurse -Filter *.log

for your example I think you can do :

$alldirs=ls E: -recurse -directory

$alldirs|%{ 
    $nb=(ls -filter *.log).count
    if ($nb -gt $WARNING){
        "This Folder $_ is having > $nb < *.log files   "
    }
}
Loïc MICHEL
  • 24,935
  • 9
  • 74
  • 103
  • Thank you ... this helps but I got this script on msdn. I worked on a physical drive, but not on mount points. May you can have a look at this? http://social.technet.microsoft.com/Forums/systemcenter/de-DE/d0a3ce2c-a02d-4491-a872-2aa15d41b848/anzeige-von-dateien-pro-ordner?forum=powershell_de – user3627902 May 12 '14 at 11:52
  • what are you trying to do exactly? get-childitem is working fine within mountpoints ... – Loïc MICHEL May 12 '14 at 11:57
  • this is the script. It's working great on physical drives, but if e: is having mount points the search won't work: $DATASTORE = "E:\" $WARNING=1 $ALLFOLDERS = [System.IO.Directory]::GetDirectories($DATASTORE,"*","AllDirectories") foreach ($Folder in $ALLFOLDERS) { $ANZAHL= ([System.IO.Directory]::GetFiles($Folder,"*.log","TopDirectoryOnly")).count if ($ANZAHL -gt $WARNING) { "This Folder $Folder is having > $ANZAHL < *.log files" } } – user3627902 May 12 '14 at 12:04
  • sorry, but I dont know how to add the source code. :-( – user3627902 May 12 '14 at 12:05