Saturday, November 14, 2015

Native support for junctions, symbolic links and hard links in PowerShell 5

The file system provider for PowerShell has been enhanced in version 5 to natively handle junctions, symbolic links, and hard links. In the past you had to use twitchy command line tools to work with these. Now you can simply use the *-*Item commands.

001
002
003
004
005
006
007
008
# Junction
New-Item -ItemType Junction     -Path D:\      -Name TestFolder2  -Value D:\Test

# Symbolic link
New-Item -ItemType SymbolicLink -Path D:\Test2 -Name TestFile.txt -Value D:\Test\test1.txt

# Hard link
New-Item -ItemType HardLink     -Path D:\Test3 -Name TestFile2.txt -Value D:\Test\test1.txt

I may have a future article that explains what these are and how they may useful for you. For now, I just wanted to get the word out to the people that have had the misfortune to already know what they are and tried to automate them, so that we can all rejoice.

No comments:

Post a Comment