【发布时间】:2015-02-25 16:15:17
【问题描述】:
我在服务器 A(开发盒)上创建到服务器 B(IIS 服务器)的远程 Powershell 会话。该脚本从服务器 C(构建机器)复制到服务器 B。
我通过了(我认为)多跳凭证问题,除了副本复制到服务器 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
}
为什么它不听我的目的地?
【问题讨论】:
-
help about_Remote_Variables
标签: powershell powershell-3.0 powershell-remoting