PowerShell Event ID 142 WSMan operation CreateShell failed, error code 2150858770

Anonymous
2024-06-12T02:53:30+00:00

All,

I have a Server that suddenly in the last few days isn't accepting PowerShell Sessions or Exchange Management Shell Sessions. This is the error from the PS console:

Normal PowerShell:

Enter-PSSession

cmdlet Enter-PSSession at command pipeline position 1
Supply values for the following parameters:
ComputerName: server.domain.com
Enter-PSSession : Connecting to remote server server.domain.com failed with the following error message
: The client cannot connect to the destination specified in the request. Verify that the service on the destination is
running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:1

  • Enter-PSSession
  •     + CategoryInfo          : InvalidArgument: (server.domain.com:String) [Enter-PSSession], PSRemoting  
       TransportException  
        + **FullyQualifiedErrorId : CreateRemoteRunspaceFailed**
    
    

When launching Exchange Management Shell:

The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:1

  • New-PSSession -ConnectionURI "$connectionUri" -ConfigurationName Micr ...
  •     + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException  
        + **FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed**
    
    

What I've checked / attempted so far:

Windows Firewall is disabled

WinRM Service is set to Automatic startup and is running

Successfully run WinRM QuickConfig

Ran Enable-PSRemoting

Note: There is always a corresponding Error Event ID 142 in the Windows Remote Management | Operational Log with the error: WSMan operation CreateShell failed, error code 2150858770

Other commands and output tested:

Test-WSMan

wsmid : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd

ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd

ProductVendor : Microsoft Corporation

ProductVersion : OS: 0.0.0 SP: 0.0 Stack: 3.0

winrm get winrm/config

Config ****

MaxEnvelopeSizekb = 500

MaxTimeoutms = 60000

MaxBatchItems = 32000

MaxProviderRequests = 4294967295

Client

NetworkDelayms = 5000

URLPrefix = wsman

AllowUnencrypted = false

Auth Basic = true

Digest = true

Kerberos = true

Negotiate = true

Certificate = true

CredSSP = false

DefaultPorts

HTTP = 5985

HTTPS = 5986

TrustedHosts

Service

RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)

MaxConcurrentOperations = 4294967295

MaxConcurrentOperationsPerUser = 1500

EnumerationTimeoutms = 240000

MaxConnections = 300

MaxPacketRetrievalTimeSeconds = 120

AllowUnencrypted = false

Auth

Basic = false

Kerberos = true

Negotiate = true

Certificate = false

CredSSP = false

CbtHardeningLevel = Relaxed

DefaultPorts

HTTP = 5985

HTTPS = 5986

IPv4Filter = *

IPv6Filter = *

EnableCompatibilityHttpListener = false

EnableCompatibilityHttpsListener = false

CertificateThumbprint

AllowRemoteAccess = true

Winrs

AllowRemoteShellAccess = true

IdleTimeout = 7200000

MaxConcurrentUsers = 2147483647

MaxShellRunTime = 2147483647

MaxProcessesPerShell = 2147483647

MaxMemoryPerShellMB = 2147483647

MaxShellsPerUser = 2147483647

Get-WSManInstance winrm/config/listener -Enumerate

cfg : http://schemas.microsoft.com/wbem/wsman/1/config/listener

xsi : http://www.w3.org/2001/XMLSchema-instance

lang : en-US

Address : *

Transport : HTTP

Port : 5985

Hostname :

Enabled : true

URLPrefix : wsman

CertificateThumbprint : ListeningOn : {10.0.0.5, 127.0.0.1, ::1, fe80::5efe:10.0.0.5%3...}

I haven't found a way to fix this yet. Any suggestions?

Thanks.

Windows for business | Windows Server | User experience | PowerShell

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Anonymous
    2024-06-13T02:21:48+00:00

    Hi,

    Thank you for posting in Microsoft Support Community.

    Please add your computer to the WinRM TrustedHosts on both ends. Open Windows PowerShell and run

    Set-Item WSMan:\localhost\Client\TrustedHosts -Value 'YourComputerName'
    
    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2024-06-13T04:09:37+00:00

    Thanks for the tip.

    Issuing simply "New-PSSession" will create a session however if I attempt: "New-PSSession -ComputerName server.domain.com" I still get the error:

    New-PSSession : [server.domain.com] Connecting to remote server server.domain.com failed
    with the following error message : The client cannot connect to the destination specified in the request. Verify that
    the service on the destination is running and is accepting requests. Consult the logs and documentation for the
    WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service,
    run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". For more
    information, see the about_Remote_Troubleshooting Help topic.
    At line:1 char:1

    • New-PSSession -ComputerName server.domain.com
    •     + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin  
         gTransportException  
          + FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed
      
      

    I'm still seeing this in The Windows Remote Management Log frequently:

    Event ID: 142

    WSMan operation CreateShell failed, error code 2150858770

    What does this mean?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2024-06-14T02:11:59+00:00

    The error code 2150858770 just means "The client cannot connect to the destination specified in the request."

    0 comments No comments
  4. Anonymous
    2024-06-14T03:09:30+00:00

    This is really odd as I'm doing all of this on the local system.

    0 comments No comments
  5. Anonymous
    2024-06-24T01:49:00+00:00

    I added the trusted hosts value but I'm still getting an error: "CannotConnect, PSSessionOpenFailed"

    0 comments No comments