


The -Recurse switch is sometimes needed despite the previous statements. (Get-ChildItem $Path -Recurse -Include $Include -Force) |įunction Remove-Tree($Path,$Include='*') function Get-Tree($Path,$Include='*') $Path -Include $Include -Force) + This answer attempts to prevent that error by individually deleting the files. When deleting files recursively using a simple Remove-Item "folder" -Recurse I sometimes see an intermittent error : cannot be removed because it is not empty.
