【发布时间】:2013-08-17 01:08:46
【问题描述】:
我们的一些服务器(W2K8 R2)上周被移到云端,一旦完成,我的 powerswhell 脚本开始失败(之前工作正常),在尝试建立连接的行抛出异常,
$ExSession = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri "http://$g_strExchangeServer/PowerShell" `
-Credential $Credentials –Authentication Kerberos
下面的消息,
[subd.staging.com] Connecting to remote server failed with the following error message :
**WinRM cannot process the request**. The following error occured while using Kerberos authentication: There are currently no logon servers available to service the logon request.
Possible causes are:
-The user name or password specified are invalid.
-Kerberos is used when no authentication method and no user name are specified.
-Kerberos accepts domain user names, but not local user names.
-The Service Principal Name (SPN) for the remote computer name and port does not exist.
-The client and remote computers are in different domains and there is no trust between the two domains.
After checking for the above issues, try the following:
-Check the Event Viewer for events related to authentication.
-Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.
Note that computers in the TrustedHosts list might not be authenticated.
-For more information about WinRM configuration, run the following command: winrm help onfig. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
只有当我尝试以我们的测试域为目标时才会发生这种情况,如果我将脚本指向我们的生产域,那么它就会起作用。
所有已迁移到云端的服务器上都会显示相同的错误。
请注意,所有尚未迁移到云端的服务器都能够在两个域上运行脚本而没有任何问题。
我尝试了以下方法,但没有运气。
//Add the destination computer to the WinRM TrustedHosts configuration setting.
c:\>WinRM set winrm/config/client @{TrustedHosts="stagingserver"}
//Confirm that WinRM is properly configured.
c:\>Winrm quickconfig
//Make sure that the remote server allows commands from any machine.
PS c:\>Set-item wsman:localhost\client\trustedhosts -value *
使用 Powershell v2 和 WinRM v2
欢迎任何 cmets。
【问题讨论】:
-
可能是这样的:“-客户端和远程计算机在不同的域中,两个域之间没有信任。”尝试使用 CredSSP。以下是启用它的方法:technet.microsoft.com/en-us/library/hh849872.aspx
-
@user1578107,我试过但没有运气,c:\>enable-wsmancredssp -role client -delegatecomputer stagingserver。该命令已正确执行,因为我没有从 PS 收到任何错误,但是脚本仍然失败并显示相同的错误消息。谢谢。
-
我不确定 enable-wsmancredssp 是否允许转发新凭据。您可以尝试手动启用它(见msdn.microsoft.com/en-us/library/windows/desktop/…)
标签: powershell powershell-2.0 powershell-remoting winrm