gci -recurse -include bin,obj . | ri -recurse
I was playing around with how to get this to work, and I couldn’t seem to figure out why these commands didn’t find the same locations to delete:
- gci -recurse -include bin,obj .
- ri -recurse -force -include bin,obj -whatif .
I finally got so baffled that I RTFMed remove-item, and there was my answer. In the fine print, nestled away in an example that did what I was looking for, and in the documentation for the recurse parameter was my answer…
Deletes the items in the specified locations and in all child items of the locations.
The Recurse parameter in this cmdlet does not work properly.
Ah ha! That’s when I went to the format that I finally settled on, and everything worked.
Another blog posting mostly written to help me remember how I solved this problem the next time I encounter it!