2
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 不会出错,但不会复制任何文件

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

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

}

4

0 回答 0