Fast Recursive Delete in Powershell
by agent x51 on
Where's the horror movie? This isn't a horror blog; It just happens to be October. I still do tech things. I'll catch you all up on the horror happenings soon… as well as the pumpkin beer.
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.
End of line.