Copy-Item无法使用Remote PowerShell将文件从网络共享复制到远程服务器上的本地驱动器

时间:2016-09-15 13:09:41

标签: powershell powershell-remoting invoke-command copy-item

Set-ExecutionPolicy -ExecutionPolicy Bypass
$webServers = "remoteservername1"

$deploymentCredentials = Get-Credential


Invoke-Command -ComputerName $webServers -Credential $deploymentCredentials -ScriptBlock {


$appVersionDirectory = "C:\Test"

New-Item创建目录没有问题:

New-Item -ItemType directory -Path $appVersionDirectory

复制项不会出错,但不会复制任何文件

如果我直接在远程服务器上运行同一个Copy-Item命令,它就可以工作!

$sourceFiles = "\\sourceserver\DeploymentSource\shared\*"
Copy-Item  $sourceFiles -Destination $appVersionDirectory

}

0 个答案:

没有答案