jed*_*atu 6 powershell hardlink
我想使用PowerShell社区扩展PSCX命令行管理器New-Hardlink http://pscx.codeplex.com/创建一个新的Hardlink .我已经阅读了man文件并尝试了几乎所有命令的组合,但它不起作用.我错过了什么?(我知道fsutil,但我想使用这个命令行开关/别名)
这是目录结构:E:\ Source 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"
Run Code Online (Sandbox Code Playgroud)
这是假设的语法:
New-Hardlink [-Path] <String> [-Target] <String> [<CommonParameters>]
-Path <String>
Path to the new link.
-Target <String>
Target of the link.
Run Code Online (Sandbox Code Playgroud)
结果总是来自:
New-Hardlink : Unable to find the file 'E:\Source.
Run Code Online (Sandbox Code Playgroud)
此命令不适用于目录,只适用于文件吗?
我会怯懦地回答我自己的问题.
是的,确实硬链接是指文件.要使用目录完成此操作,应使用New-Junction命令,如下所示:
New-Junction E:\Test\Dest E:\Source
Run Code Online (Sandbox Code Playgroud)
第一个参数指的是您想要放置新Junction的位置.
第二个参数指的是您希望连接的目录
小智 5
Powershell 5+ 包含创建任何类型的硬/软链接和连接的本机方法。
对于来自 Google 的用户:
PowerShell 5.0 及更高版本支持使用New-Itemcmdlet 创建符号链接和连接。
在下面,点击B.txt将会带您到A.txt。对于目录也是如此。
# 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3182 次 |
| 最近记录: |