How to create Hardlink using the PowerShell PSCX New-Hardlink Command

I want to create a new Hardlink using PowerShell PSCX extension commands. New-Hardlink http://pscx.codeplex.com/ . I read the man file and tried almost every combination of commands, but it will not 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 a few options for the command I 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 suggested syntax:

 New-Hardlink [-Path] <String> [-Target] <String> [<CommonParameters>] -Path <String> Path to the new link. -Target <String> Target of the link. 

As a result, there is always a result:

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

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

+6
powershell hardlink
source share
2 answers

I will be confused to answer my question.

Yes, indeed, Hardlinks relate to files. To accomplish this using directories, the New-Junction command should be used as follows:

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

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

The second parameter refers to the directory you want to mount

+8
source share

For Google users:

PowerShell 5.0 and later support creating symbolic links and connections using the New-Item cmdlet.

To create a symbolic link to a file:

By clicking on B.txt, you will be taken to A.txt.

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 symbolic link in a directory:

New-Item -ItemType SymbolicLink -Name B_Directory -Target C:\A_Directory

New-Item -ItemType HardLink -Path C:\B.txt -Value C:\A.txt

To create a connection in the directory:

New-Item -ItemType Junction -Path C:\Junction -Value C:\A_Directory

0
source share

All Articles