将文件从网络共享复制到远程PC的硬盘上



我有这个测试设置:

# Attach a network drive to X
net use X: \MySharenameExchange /user:MyUser MyPassword
# copy test.txt file from share to a remote computer D (Dev)
copy X:test.txt MyComputerNameOrIPD:

如何在语法上正确地编写目标系统"MyComputerNameOrIPD:"

我想复制/粘贴test.txt文件到另一台电脑的硬盘D:

net use X: /delete
# Attach a network drive to X:
net use X: \MyShareExchange /user:myuser mypass
# copy test.txt file from share to a remote computer D (Dev)
Copy-Item -Path X:test.txt '\MyComputernameD$'

然后我得到错误:"Copy-Item: the network path was not found."

][Step 5/5] X: was deleted successfully.
[12:59:36][Step 5/5] 
[12:59:36][Step 5/5] The command completed successfully.
[12:59:36][Step 5/5] 
[13:00:19][Step 5/5] Copy-Item : The network path was not found.
[13:00:19][Step 5/5] At C:TeamCitybuildAgenttempbuildTmppowershell1776282632632814927.ps1:7 
[13:00:19][Step 5/5] char:1
[13:00:19][Step 5/5] + Copy-Item -Path X:test.txt '\MyComputernameD$'
[13:00:19][Step 5/5] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[13:00:19][Step 5/5]     + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
[13:00:19][Step 5/5]     + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Comma 
[13:00:19][Step 5/5]    nds.CopyItemCommand
[13:00:19][Step 5/5] 

计算机名当然是为了SO而伪造的…

你可以这样做:Copy-Item -Path X:Test.txt '\MyComputerNameOrIPD$'

最新更新