It seems that Remove-Item -Recurse -Force
cannot deal with removing symlinks. How do I recursively delete everything from a given directory with symlinks made all over the place?
MWE:
PS C:\Users\Administrator\Desktop\test> mkdir foo
Directory: C:\Users\Administrator\Desktop\test
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/30/2020 11:58 AM foo
PS C:\Users\Administrator\Desktop\test> mkdir bar
Directory: C:\Users\Administrator\Desktop\test
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 7/30/2020 11:58 AM bar
PS C:\Users\Administrator\Desktop\test> New-Item -ItemType SymbolicLink -Path foo -Name bar -Value C:\Users\Administrator\Desktop\test\bar
Directory: C:\Users\Administrator\Desktop\test\foo
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----l 7/30/2020 11:59 AM bar
PS C:\Users\Administrator\Desktop\test> Remove-Item -Recurse -Force foo
Remove-Item : There is a mismatch between the tag specified in the request and the tag present in the reparse point
At line:1 char:1
+ Remove-Item -Recurse -Force foo
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Remove-Item], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.RemoveItemCommand
-Recurse
toGet-ChildItem
, maybe. – Lucey