powershell 깨진 symlink를 제거하는 방법 : WriteError: (C:\testlink:DirectoryInfo) [Remove-Item],

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 / shell 버그는 어디에보고 할 수 있습니까? powershell이 ​​ms connect에없는 것 같습니다.



답변

시험:

cmd /c rmdir testlink

cmd 몰라 rm


답변

mountvol / d 명령을 사용하십시오.

GUID를 나열하십시오.

PS C :> 마운트 볼

그때

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

위의 관련 GUID 교체


답변

powershell의 .net을 사용 하여이 작업을 수행합니다.

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

여기서 $ Path는 심볼릭 링크의 경로와 같습니다. rmdir은 일관된 결과를 제공하지 않으며 powershell에서 실행될 때 성공 여부와 상관없이 거의 항상 오류를 반환합니다.