13 December 2016

Remote PowerShell session - the request needs to be sent to a different machine

Well this is a nice one as well….NOT. I keep losing hair like this.
After trying to setup a remote PowerShell session the following error occurs.

The WinRM service cannot process the request because the request needs to be sent to a different machine.
Use the redirect information to send the request to a new machine.  Redirect location reported: https://mail.mydomain.com/powershell.
To automatically connect to the redirected URI, verify "MaximumConnectionRedirectionCount" property of session preference variable
"PSSessionOption" and use "AllowRedirection" parameter on the cmdlet.
+ CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportRedirectException
+ FullyQualifiedErrorId : PSSessionOpenFailed

Let me tell you what is not the cause so you can skip checking all those things:
  • An URL redirect in IIS
  • Reinstall of WinRM
  • adding “–AllowRedirect” after your connection command let
  • "MaximumConnectionRedirectionCount" property setting
  • Misconfigured certificate
  • PowerShell version
  • Invalid credentials
The list could go on and on, but the solution is quite simple as it is not logic at the same time.
The error doesn't say a lot about the actual cause.
So remember when was the last CU you installed? Bingo, after every CU your IIS settings can get garbled and that’s exactly what happened here.
Changes are your authentication settings in IIS on the PowerShell virtual directory for the frontend website are gone/missing/set incorrectly.
In my case they were gone, no authentication option was set. After setting it al back the way it should be (see this post, you need to make note of this stuff for a working Exchange environment in cases like this) I could create a remote PowerShell session instantly.

3 comments:

  1. Anonymous3/8/17 12:57

    you saved my day! Actually all types of authentication have been disabled on my Exchange Servers (apparently during last updates). After enabling basic authentication remote powershell Connections work as before.

    ReplyDelete
    Replies
    1. Yeah, it really helps, enabling basic (windows authentication not working) makes all work as before!

      Delete
  2. Anonymous17/8/17 06:45

    Good replies in return of this issue with genuine arguments and describing all about that.

    ReplyDelete