views:

277

answers:

1

I want to create a new Hardlink with the PowerShell Community Extensions PSCX commandlet New-Hardlink http://pscx.codeplex.com/. I have read the man file and tried almost every combination of commands but it won't work. What am I missing? (I know about fsutil, but I want to use this commandlet/alias)

Here is the directory structure: E:\Source E:\Test

Here are some variations of the command that I have tried:

New-Hardlink E:\Test\Source E:\Source
New-Hardlink -Path:"E:\Test\Source" -Target:"E:\Source"
New-Hardlink E:\Source E:\Test\Source
New-Hardlink E:\Source E:\Test\
New-Hardlink -P:"E:\Source" -T:"E:\Test\Source"

Here is the supposed syntax:

New-Hardlink [-Path] <String> [-Target] <String> [<CommonParameters>]

-Path <String>
    Path to the new link.

-Target <String>
    Target of the link.

The result is always some from of:

New-Hardlink : Unable to find the file 'E:\Source.

Does this command not work with directories but only with files?

+4  A: 

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

jedatu