私の問題はPowershellにあります。私は非常に大きなフォルダを持っています。インサイダーは約160万のサブフォルダーです。私の仕事は、6か月以上経過した空のフォルダまたはその下のファイルをすべて消去することです。foreachを使用してループを作成しましたが、PowerShellがループを開始するまでには何年もかかります->
..。
foreach ($item in Get-ChildItem -Path $rootPath -recurse -force | Where-Object -FilterScript { $_.LastWriteTime -lt $date })
{
# here comes a script which will erase the file when its older than 6 months
# here comes a script which will erase the folder if it's a folder AND does not have child items of its own
..。
問題:内部メモリがいっぱいになり(4GB)、正しく動作しなくなりました。私の推測では、PowerShellは1 600 000個のフォルダーをすべてロードし、その後でのみそれらのフィルター処理を開始します。
これを防ぐ可能性はありますか?