mardi 28 juillet 2020

PowerShell: How to use remove-item to delete files in batches?

I have a small script which deletes files from a directory where date1 is less than date2. My script is working, however, as this is run on a directory with many files, I'd like the remove item to only remove 100 files at a time, so that I can monitor the progress with each run. Is this possible?

 if ($date1 -lt $date2) 
                { 
                    $_ | Remove-Item;
               }

Aucun commentaire:

Enregistrer un commentaire