我在服务器A(开发盒)创建远程Powershell会话到服务器B(IIS服务器)。从服务器C(建机)的脚本复制到服务器B.PowerShell复制项远程机器复制到错误的位置
我得以通过(我认为)的多跳凭证问题,除了副本复制到错误的位置上服务器B.
这是应该复制到d:\ wwwroot \ HelloWorld,而是复制到c:\ users \ me \ Documents \ HelloWorld。
所有服务器都是Win2012r2,并且在使用PowerShell v3的域上。
服务器B运行:
winrm set winrm/config/service/auth '@{CredSSP="true"}'
在服务器A上运行:
winrm set winrm/config/client/auth '@{CredSSP="true"}'
这里是我的脚本:
$password = ConvertTo-SecureString "mypassword" -AsPlainText -Force
$cred= New-Object System.Management.Automation.PSCredential ("mydomain\me", $password)
$sesh = new-pssession -computername "ServerB" -credential $cred -Authentication CredSSP
$sitePath = "D:\wwwroot\HelloWorld"
Invoke-Command -Session $sesh -ScriptBlock {
Copy-Item -path "\\ServerC\Builds\HelloWorld\HelloWorld.1\_PublishedWebsites\HelloWorld" -Destination $sitePath -Recurse -Force
}
为什么没有听我的目的地?
'帮助about_Remote_Variables' – PetSerAl 2015-02-24 20:47:41
https://technet.microsoft。 com/en-us/library/jj149005.aspx – jessehouwing 2015-02-24 20:50:51