powershell how to remove broken symlink

Solution 1:

Try:

cmd /c rmdir testlink

cmd doesn't know about rm

Solution 2:

Use the mountvol /d command

List the GUID:

PS C:> Mountvol

then

PS C:> mountvol \?\Volume{2eca078d-5cbc-43d3-aff8-7e8511f60d0e}\ /d

replacing the relevant GUID in the above

Solution 3:

I use .net from powershell to do this

[System.IO.Directory]::Delete($Path,$true)

Where $Path is equal to the path of your symlink. rmdir does not provide consistent result and will almost always return an error when run from powershell, regardless if it was successful or not.