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

时间:2015-07-23 09:59:50

标签: powershell powershell-v4.0

我有这个测试设置:

# Attach a network drive to X
net use X: \\MySharename\Exchange /user:MyUser MyPassword

# copy test.txt file from share to a remote computer D (Dev)
copy X:\test.txt MyComputerNameOrIP\D:\

我如何在语法上正确地编写目标系统" MyComputerNameOrIP \ D:\"

我想将test.txt文件从Share X复制/粘贴到另一台计算机的硬盘D:\

更新

net use X: /delete

# Attach a network drive to X:
net use X: \\MyShare\Exchange /user:myuser mypass

# copy test.txt file from share to a remote computer D (Dev)
Copy-Item -Path X:\test.txt '\\MyComputername\D$'

然后我收到错误:" Copy-Item:找不到网络路径。"

][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:\TeamCity\buildAgent\temp\buildTmp\powershell1776282632632814927.ps1:7 

[13:00:19][Step 5/5] char:1

[13:00:19][Step 5/5] + Copy-Item -Path X:\test.txt '\\MyComputername\D$'

[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] 

计算机名称当然是伪造的......

1 个答案:

答案 0 :(得分:0)

你可以这样做:     dateString = dateValue.ToString("yyyy'/'MM/'/'dd hh':'mm':'ss");