PowerShell如何删除损坏的符号链接

PS C:\> cmd /c mklink /d testlink non-existent-dir symbolic link created for testlink <<===>> non-existent-dir PS C:\> rm .\testlink Remove-Item : C:\testlink is a NTFS junction point. Use the Force parameter to delete or modify. At line:1 char:3 + rm <<<< .\testlink + CategoryInfo : WriteError: (C:\testlink:DirectoryInfo) [Remove-Item], IOException + FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.RemoveItemCommand PS C:\> rm -force .\testlink Remove-Item : Could not find a part of the path 'C:\testlink'. At line:1 char:3 + rm <<<< -force .\testlink + CategoryInfo : WriteError: (C:\testlink:String) [Remove-Item], DirectoryNotFoundException + FullyQualifiedErrorId : RemoveItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand PS C:\> 

错误与rm -force尝试删除链接指向的内部项目有关。 我怎样才能使用命令行删除这个东西? 我在哪里可以报告PowerShell /壳错误? 看来PowerShell不在MS连接。

尝试:

 cmd /c rmdir testlink 

cmd不知道关于rm

使用mountvol / d命令

列出GUID:

PS C:> Mountvol

然后

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

在上面replace相关的GUID

我使用.net从PowerShell来做到这一点

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

其中$ Path等于你的符号链接的path。 rmdir不提供一致的结果,并且在从powershell运行时几乎总是返回一个错误,无论它是否成功。