>我正在尝试从server01运行下面的powershell脚本。我在 server03 上有帐户,所以没有传递凭据。即使我通过了它,也会出现相同的错误消息。
我的帐户在域 A 和服务器 01 上,服务器 03 在域 B 上。如果我使用属于域 B 的另一个帐户登录 server01,则该脚本有效。
在执行跨域 PS 之前,还需要启用什么吗?
Invoke-Command -ComputerName server03 -FilePath E:testtest.ps1
[Server03] Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authentication: The network path was not found.
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 us
e 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 config. For more information,
see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (:) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionStateBroken
我已经为服务器添加了FDQN,它工作正常。
Invoke-Command -ComputerName server03.domain.com -FilePath E:test\test.ps1
-
您需要在受信任的主机列表中添加计算机。
-
检查属于受信任主机列表的服务器。
Get-Item WSMan:localhostClientTrustedHosts
Set-Item WSMan:localhostClientTrustedHosts -Value “IPAddress or *”
然后继续执行命令。