Reputation: 109
I am trying to scan a shared network drive, containing many thousands of files, for only Word files that haven't been modified in the past year. While what I wrote works, it is extremely slow. I have multiple drives I need to scan and it take hours. Is there anything I can do to speed it up?
gci \\RemoteServer\ -filter *.docx -recurse -force | %{write-progress -Status $_ -Activity "Scanning old Word files...";$_} | ? {$_.lastwritetime -ge '1/1/13' -AND $_.lastwritetime -le '12/30/13'} | measure-object
I did see this but am not sure how I would / could apply the date range to that search.
I also know that the write-progress
slows it down, but since the first run took several hours I wanted to know it was alive.
Any help or guidance would be appreciated.
Upvotes: 2
Views: 492
Reputation: 68331
Try this:
Switch -Wildcard ((cmd /c dir \\Server\Share\*.docx /S /A-D) -match 'Directory of|^\d\d/\d\d/2013')
{
'*Directory of*' {$directory = $_.replace(' Directory of ','')}
Default {'{2} {0}\{1}' -f $directory,($_ -split '\s+',4)[-1],$_.split(' ')[0] }
}
Upvotes: 1