Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
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:\>

The error is related to the fact that rm -force tries to remove items inside wherever the link is pointing. How can I remove this thing using the command line? Where can I report powershell/shell bugs? It seems powershell is not on ms connect.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

Try:

cmd /c rmdir testlink

cmd doesn't know about rm

share|improve this answer
    
Works, now where could let MS know about this bug? –  Ian Kelling Sep 23 '09 at 0:38
    
PS doesn't have mklink yet so it makes sense that it doesn't know how to deal with broken ones. I'd call it a "feature request" rather than a "bug". I would imagine it's already on the roadmap. Here's a link for feedback, however: connect.microsoft.com/PowerShell –  Dennis Williamson Sep 23 '09 at 5:11
    
thanks. Don't know how I missed the ms connect link before. –  Ian Kelling Sep 23 '09 at 7:02

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.

share|improve this answer

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

share|improve this answer
    
There's no indication of which volume corresponds to the broken symlink I want to delete. –  Ian Kelling Sep 23 '09 at 0:38
    
I havent tried it yet, but I dont think that matters, just run 'mountvol' on the server and it should list all the mount points on all the volumes (along with their GUIDs) –  ss64 Sep 23 '09 at 16:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.