Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows Server 2012 R2 / The WinRM client received an HTTP bad request status (400)

September 21, 2018 Windows 10Windows Server 2012 R2

The WinRM client received an HTTP bad request status (400)

When configuring WinRM on servers in the Active Directory domain, I have faced a strange problem. After WinRM service is configured and enabled on the Windows server, and remote connection to it is allowed through Windows PowerShell Remoting, the following WinRM error appears in PowerShell console after the attempt of the remote connection to the server using Enter-PSSession lon-dc1 command:

PS C:\Windows\system32> Enter-PSSession lon-dc01

Enter-PSSession : Connecting to remote server lon-dc1 failed with the following error message : The WinRM client received an HTTP bad request status (400), but the remote service did not include any other information about the cause of the failure. For more information, see the about_Remote_Troubleshooting Help topic.

At line:1 char:1

+ Enter-PSSession lon-dc1

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: (lon-dc1 :String) [Enter-PSSession], PSRemotingTransportException

+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed

Also you can see the following error message:

The WinRM client cannot process the request. It cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid.

The WinRM client received an HTTP bad request status (400), but the remote service did not include any other information about the cause of the failure

At the same time WinRM ports on the server (5985/HTTP, 5986/HTTPS) respond and accept connections. You can check the availability of WinRM TCP ports using PortQry tool or Test-NetConnection PowerShell cmdlet:

TNC lon-dc1 –port 5985

test winrm port TCP 5985 response

As it turned out, the problem was relatedted with the large size of Kerberos token of a user due to the user being a member of too many domain security groups. The error appears when the size of the token exceeds 16 KB (see the article Kerberos MaxTokenSize and Security Groups). In our case, it happens in the same way, WinRM server resets the request from a client, since the size of the authentication package header exceeds 16 KB. In the article on the link above we mentioned that the default HTTP header on IIS is no more than 16 KB, and in case of problems with HTTP authentication due to a large user token, it needs to be increased to 64 KB.

To fix the problem, you need to reduce the token size (reduce the number of security groups a user is a member of), and if it is not possible, change the values of the following DWORD parameters on the server registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters .

  • MaxFieldLength increase to 0000ffff (65535);
  • MaxRequestBytes increase to 0000ffff (65535).

http header MaxFieldLength

Now just restart your server and check your WinRM connection from the remote client using Enter-PSSession.

 

0 comment
0
Facebook Twitter Google + Pinterest
previous post
How to Install Hyper-V Role in Windows 10 VM under VMWare ESXi
next post
How to Convert Install.ESD to the Bootable .ISO Image in Windows 10

Related Reading

How to Run Program without Admin Privileges and...

March 24, 2023

Configure Network Settings on Windows with PowerShell: IP...

March 24, 2023

Attaching Host USB Devices to WSL or Hyper-V...

March 20, 2023

Print Screen Key Not Working in Windows

March 17, 2023

Fix: Remote Desktop Services Is Currently Busy

March 15, 2023

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Run Program without Admin Privileges and Bypass UAC Prompt?

    March 24, 2023
  • Configure Network Settings on Windows with PowerShell: IP Address, DNS, Default Gateway, Static Routes

    March 24, 2023
  • Exchange Offline Address Book Not Updating in Outlook

    March 21, 2023
  • Attaching Host USB Devices to WSL or Hyper-V VM

    March 20, 2023
  • Sending an E-mail to a Microsoft Teams Channel

    March 17, 2023
  • How to Restore Deleted Users in Azure AD (Microsoft 365)?

    March 16, 2023
  • Fix: Remote Desktop Services Is Currently Busy

    March 15, 2023
  • Send-MailMessage: Sending E-mails with PowerShell

    March 14, 2023
  • Clear Cache and Temp Files in User Profiles on Windows (RDS) with PowerShell and GPO

    March 13, 2023
  • Prevent Users from Creating New Groups in Microsoft 365 (Teams/Outlook)

    March 6, 2023

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Booting Windows 7 / 10 from GPT Disk on BIOS (non-UEFI) systems
  • Error Code: 0x80070035 “The Network Path was not found” after Windows 10 Update
  • Removable USB Flash Drive as Local HDD in Windows 10 / 7
  • How to increase KMS current count (count is insufficient)
  • How to Disable UAC Prompt for Specific Applications in Windows 10?
  • Managing Printers and Drivers with PowerShell in Windows 10 / Server 2016
  • Managing Printers from the Command Prompt in Windows 10 / 8.1
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top