介绍

介绍

介绍

我现在坐在 Windows Server 2012 R2 服务器上,正在尝试Enter-PSSession进入另一台机器。

我已经Enable-PSRemoting在远程计算机上执行过,但没有帮助。

计算机详细信息

本地计算机

  • 操作系统:Windows Server 2012 R2
  • IP 10.1.1.1/24
  • HOSTNAME.exe: 服务器
  • ECHO %USERNAME%:用户1
  • ECHO %USERDOMAIN%: 例子
  • WHOAMI.exe:示例\用户1
  • 域名"control.exe system":example.test
  • 完整计算机名称"control.exe system":server.example.test
  • $PSVersionTable.PSVersion | FT -H:5 0 10586 117

远程计算机

  • 操作系统:Windows 7 企业版
  • IP 10.1.1.2/24
  • HOSTNAME.exe:工作站
  • ECHO %USERNAME%: 行政人员
  • ECHO %USERDOMAIN%:工作站
  • WHOAMI.exe:工作站\管理员
  • 域名"control.exe system":example.test
  • 完整计算机名称"control.exe system":workstation.example.test
  • $PSVersionTable.PSVersion | FT -H:2 0 -1 -1

我尝试过的方法

来自 server.example.test 的尝试 1-6:

PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential Administrator
PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential example\Administrator
PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential example.test\Administrator
PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential User1
PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential example\User1
PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential example.test\User1

这些都得到相同的输出:

Enter-PSSession : Connecting to remote server workstation.example.test failed with the following error message : The user name or password is incorrect. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName workstation.example.test -credential Admin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (workstation.example.test:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

这没有意义,因为我绝对肯定密码是正确的。

从 server.example.test 尝试 7-8

PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential workstation\Administrator
PS C:\Users\User1> Enter-PSSession -ComputerName workstation.example.test -credential workstation\User1

它们都得到这样的输出:

Enter-PSSession : Connecting to remote server workstation.example.test failed with the following error message : WinRM cannot process the request. The following error with errorcode 0x80090311 occurred 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 config. For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName workstation.example.test -credential works ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (workstation.example.test:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

有人知道为什么这不起作用吗?

答案1

我费尽心思写了这篇文章,并在发布之前解决了它,所以如果你遇到了同样的问题,希望这会有所帮助。

在 server.example.test 上,以管理员身份打开 PowerShell 并输入以下命令之一:

  1. Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value *
  2. Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value *.example.test
  3. Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value workstation.example.test

第一个将允许您的本地计算机连接到任何远程计算机。

第二个将允许远程访问 example.test 域上的任何计算机。

第三个将仅允许远程访问workstation.example.test。

我认为添加多个条目的语法只是一个逗号分隔的值字符串,它看起来像这样:

Set-Item -Path WSMan:\localhost\Client\TrustedHosts -Value "192.168.0.1,192.168.0.2"

相关内容