Created
November 6, 2015 13:49
-
-
Save nvnivs/22c99bb55ef82127ffe6 to your computer and use it in GitHub Desktop.
Create a junction path between two folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# REMARK: By default UNC to local junctions are disabled | |
# To find out run 'fsutil behavior query SymlinkEvaluation' | |
# To enable run 'fsutil behavior set SymlinkEvaluation R2L:1' | |
$source = 'd:\folder-a' | |
$target = 'd:\folder-b' | |
Robocopy $source $target /MIR /R:12 /W:5 | |
Invoke-Expression "cmd.exe /c attrib +r $source\\*.* /s" | |
Write-Host "Set source to read only" | |
Robocopy $source $target /MIR /R:12 /W:5 | |
Write-Host "Moved source to $source-backup" | |
Move-Item $source "$source-backup" -ErrorAction Stop | |
Invoke-Expression "cmd.exe /c mklink /D $source $target" | |
Write-Host "Unset target read only" | |
Invoke-Expression "cmd.exe /c attrib -r $target\\*.* /s" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment