Powershell Remoting through Load Balancers : The "select or value was not found" problem

Powershell remoting is supported over load balancers with configuration described at https://msdn.microsoft.com/en-us/library/ee309370(VS.85).aspx#load_balancing_in__the__iis_extension_hosting_model

Users when trying to use this feature may hit a problem that breaks an active runspace with an error that looks like the following:

"the select or value F8037657-C31F-4B2F-9BCA-CAD89BC7C9F1 specified in the request was not found.

"

 

The above error ideally means that the runspace does not exist or has already expired. However, users may hit this even when the remote runspace is active in a load balancer scenario. This will happen when winrm (the underlying transport protocol) uses multi-handshake auth protocols like Kerb, Negotiate or CredSSP. 

There were two workaround to this issue:

- Configure LB to explicitly set the outbound cookie on every response (the default behavior is to set only on the request that did not have any cookie set)

- Adding a custom HTTP module on the IIS endpoint to replays back the cookie on every response