There are times somehow someone or some process managed to create files or directories longer than 260 character limit on Windows. If you try to delete them, Remove-Item or any other delete attempt errors out because well, Windows can’t really handle the long path well.
Here is a trick. Robocopy can deal with something like that pretty well. Here are the steps.
- Create an empty folder such as C:\empty
- Execute the following robocopy command to mirror the empty folder with the destination folder you want to clean up.
robocopy C:\empty C:\some\path\you\wanna\clean /MIR
Rocopy for the rescue!