Copy-Item适用于IP地址,而不适用于计算机名称

时间:2014-09-18 18:18:59

标签: powershell copy-item

如果我使用其IP地址10.10.10.10

,以下代码会将文件复制到remote_computer
$j = "remote_computer"

New-PSDrive -Name Z -PSProvider FileSystem -Root \\$j\share -Credential $credentials -ErrorAction Stop 

Copy-Item -Path D:\ps_*able.ps1 -Destination \\10.10.10.10\share

Remove-PSDrive -name Z

如果我使用Z,即psdrive

,此脚本不会复制文件
$j = "remote_computer"

New-PSDrive -Name Z -PSProvider FileSystem -Root \\$j\share -Credential $credentials -ErrorAction Stop 

Copy-Item -Path D:\ps_*able.ps1 -Destination Z

Remove-PSDrive -name Z

如何解决?

1 个答案:

答案 0 :(得分:2)

" Z"不是有效路径

Copy-Item -Path D:\ps_*able.ps1 -Destination Z:\
相关问题