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
}