เมื่อตั้งค่า WinRM บนเซิร์ฟเวอร์ใน Active Directory Domain พบปัญหาแปลก: หลังเปิดใช้งาน WinRM Service และอนุญาต Remote Connection ผ่าน PowerShell Remoting พยายามเชื่อมต่อ Remote ด้วย Enter-PSSession lon-dc1 ได้ Error:
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.
อาจเห็น Error เพิ่มเติม: 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.
แต่ WinRM Ports (5985/HTTP, 5986/HTTPS) ตอบสนองและรับ Connection ได้ ตรวจสอบด้วย TNC lon-dc1 –port 5985 → Port เปิดอยู่
สาเหตุจริง
ปัญหาเกิดจาก Kerberos Token Size ของ User ใหญ่เกินไป เนื่องจาก User เป็นสมาชิกของ Security Groups ใน Domain มากเกินไป Error เกิดขึ้นเมื่อ Token Size เกิน 16 KB (ดูรายละเอียดในบทความ Kerberos MaxTokenSize and Security Groups) WinRM Server ปฏิเสธ Request จาก Client เพราะ Authentication Package Header ใหญ่เกิน 16 KB
วิธีแก้ไข
ลด Token Size (ลดจำนวน Security Groups) หากทำไม่ได้ ให้เปลี่ยนค่า DWORD ใน Registry Key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters:
- MaxFieldLength =
0000ffff(65535) - MaxRequestBytes =
0000ffff(65535)
รีสตาร์ทเซิร์ฟเวอร์ แล้วทดสอบ WinRM Connection ใหม่ด้วย Enter-PSSession