How to create a Hardlink using the New-Hardlink PowerShell PSCX command

I will sheepishly answer my own question.

Yes, indeed Hardlinks refer to files. To accomplish this with directories the New-Junction command should be used like so:

New-Junction E:\Test\Dest E:\Source

The first parameter refers to the location you would like to place the new Junction.

The second parameter refers to the directory you wish to Junction


Powershell 5+ include a native way to create any types of hard-/soft-links and junctions.

For those coming from Google:

PowerShell 5.0 and above have support for creating Symbolic Links and Junctions using the New-Item cmdlet.

In the following, clicking on B.txt will take you to A.txt. Similarly for a directory.

# To create a symbolic link on a file:
New-Item -ItemType SymbolicLink -Name B.txt -Target A.txt
New-Item -ItemType SymbolicLink -Path C:\Temp\B.txt -Value A.txt

# To create a hard-link on a file:
New-Item -ItemType HardLink -Path C:\B.txt -Value C:\A.txt

# To create a symbolic link on a directory:
New-Item -ItemType SymbolicLink -Name B_Directory -Target C:\A_Directory

# To create a junction on a directory:
New-Item -ItemType Junction -Path C:\Junction -Value C:\A_Directory