Can I make this script even faster?
问题 I wrote a simple script for an internship, which trawls through a provided directory and deletes any file older than a specified number of days. I've spent all my free time today attempting to tighten it up. Here's what I've got so far: function delOld($dir, $numDays){ $timespan = new-timespan -days $numDays $curTime = get-date get-childItem $dir -Recurse -file | where-object {(($curTime)-($_.LastWriteTime)) -gt $timespan} | remove-Item -whatif } Here is an example of a call of the function: