Skip to content

Instantly share code, notes, and snippets.

@brianlow
Created September 16, 2014 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianlow/0d5d2070c87c378454d7 to your computer and use it in GitHub Desktop.
Save brianlow/0d5d2070c87c378454d7 to your computer and use it in GitHub Desktop.
rmdir deletes children through junction
D:\temp\test> mkdir source
#
#
# Directory: D:\temp\test
#
#
# Mode LastWriteTime Length Name
# ---- ------------- ------ ----
# d---- 9/15/2014 7:42 PM source
#
#
D:\temp\test> cmd /c "mklink /j dest source"
# Junction created for dest <<===>> source
D:\temp\test> echo hi > source\hello.txt
D:\temp\test> type dest\hello.txt
# hi
D:\temp\test> rmdir dest
#
# Confirm
# The item at D:\temp\test\dest has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you
# want to continue?
# [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
# rmdir : D:\temp\test\dest is a NTFS junction point. Use the Force parameter to delete or modify.
# At line:1 char:1
# + rmdir dest
# + ~~~~~~~~~~
# + CategoryInfo : WriteError: (D:\temp\test\dest:DirectoryInfo) [Remove-Item], IOException
# + FullyQualifiedErrorId : DirectoryNotEmpty,Microsoft.PowerShell.Commands.RemoveItemCommand
#
D:\temp\test> rmdir dest -force
#
# Confirm
# The item at D:\temp\test\dest has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you
# want to continue?
# [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y
D:\temp\test> type source\hello.txt
# type : Cannot find path 'D:\temp\test\source\hello.txt' because it does not exist.
#At line:1 char:1
#+ type source\hello.txt
#+ ~~~~~~~~~~~~~~~~~~~~~
# + CategoryInfo : ObjectNotFound: (D:\temp\test\source\hello.txt:String) [Get-Content], ItemNotFoundException
# + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
D:\temp\test> $PSVersionTable
#
# Name Value
# ---- -----
# PSVersion 3.0
# WSManStackVersion 3.0
# SerializationVersion 1.1.0.1
# CLRVersion 4.0.30319.18444
# BuildVersion 6.2.9200.16481
# PSCompatibleVersions {1.0, 2.0, 3.0}
# PSRemotingProtocolVersion 2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment