Fast Recursive Delete in Powershell
by Michael Szul on
No ads, no tracking, and no data collection. Enjoy this article? Buy us a ☕.
Dropping a quick note on Powershell, which is a powerful language with a terrible syntax.
If you want to recursively delete files and folders, don't do this:
Remove-Item $d.FullName -Recurse -Force -Verbose
It will be slow.
Do this:
$d.Delete($true);
Much faster. In this case $d
is the variable representing the file system object you want to delete recursively.