大网数据广告活动
Windows Server 管理

Can't establish a PowerShell remote session using WinRM

· 52CE 我爱测

Helps to resolve the issue in which a PowerShell remote session using Windows Remote Management (WinRM) can't be established between machines that are joined to Microsoft Entra-only.

This article helps to resolve the issue in which a PowerShell remote session using Windows Remote Management (WinRM) can't be established between machines that are only joined to Microsoft Entra ID.

You have two machines on the same network. They aren't joined to a local domain and only joined to Microsoft Entra ID with no on-premises synchronization.

When you try to establish a PowerShell remote session using WinRM between the two machines, you receive the following error messages:

  • Enter-PSSession : Connecting to remote server CLIENT01 failed with the following error message : The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.

  • Enter-PSSession : Connecting to remote server CLIENT01 failed with the following error message : WinRM cannot process the request. The following error with errorcode 0x8009030e occurred while using Negotiate authentication: A specified logon session does not exist. It may already have been terminated.
    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.

This issue occurs because of one of the following reasons:

  • WinRM considers the Microsoft Entra-only joined machines as workgroup machines. Therefore, implicit credentials can't be used.
  • The WinRM default Service Principal Name (SPN) prefix HTTP prevents Microsoft Entra authentication.

Implicit credentials can't be used

To resolve this issue, set the TrustedHosts value as follows:

Value Description
* This value allows reusing the implicit credentials for all target machines.
*.contoso.com This value restricts the usage of credentials to the machines of a specific domain.

For example, you can use one of the following ways to set the TrustedHosts value to *.contoso.com:

  • The PowerShell cmdlet:

    set-item WSMan:\localhost\Client\TrustedHosts "*.contoso.com"
    
  • The command prompt:

    winrm s winrm/config/client @{TrustedHosts="*.contoso.com"}
    
  • Add a registry entry from the command prompt:

    reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Client /v trusted_hosts /t REG_SZ /d "*.contoso.com" /f
    

Default SPN prefix HTTP prevents Microsoft Entra authentication

To resolve this issue, set the default SPN prefix to HOST by running the following command:

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Client /v spn_prefix /t REG_SZ /d "HOST" /f

Data collection

If you need assistance from Microsoft support, we recommend you collect the information by following the steps mentioned in Gather information by using TSS for User Experience issues.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
- Supported versions of Windows Client · Source date 02/12/2026
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。