如何使用 New-Hardlink PowerShell PSCX 命令创建硬链接
我想使用 PowerShell 社区扩展 PSCX commandlet New-Hardlink http://pscx.codeplex.com/ 创建新的硬链接。我已经阅读了 man 文件并尝试了几乎所有命令组合,但它不起作用。我缺少什么? (我知道 fsutil,但我想使用这个命令行开关/别名)
这是目录结构: E:\来源 E:\Test
以下是我尝试过的命令的一些变体:
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"
这是假定的语法:
New-Hardlink [-Path] <String> [-Target] <String> [<CommonParameters>]
-Path <String>
Path to the new link.
-Target <String>
Target of the link.
结果总是来自以下内容:
New-Hardlink : Unable to find the file 'E:\Source.
此命令不适用于目录,而仅适用于文件吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会羞涩地回答我自己的问题。
是的,硬链接确实是指文件。要通过目录完成此操作,应像这样使用 New-Junction 命令:
第一个参数指您要放置新 Junction 的位置。
第二个参数是指你要Junction的目录
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:
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
对于来自 Google 的用户:
PowerShell 5.0 及更高版本支持使用
New-Item
cmdlet。在下面,点击
B.txt
将转到A.txt
。对于目录也是如此。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 toA.txt
. Similarly for a directory.