From: guy on

You can catch the exception and redirect to the right URL

WSManConnectionInfo connInfo = new WSManConnectionInfo(..);
rs = RunspaceFactory.CreateRunspace(connInfo);
catch(PSRemotingTransportRedirectException ex)
newurl = ex.RedirectLocation;

Now you can change the connInfo with the new Url and try to open the Runspace again.

Hope it helps.


NZSchoolTech wrote:

PSRemotingTransportRedirectException exception thrown with WSManConnectionInfo

Good day,

I am working with an app that is a Powershell host and makes a connection to
a remote Powershell session for Exchange 2010 (Outlook Live) by specifying
the URI in an instance of WSManConnectionInfo.

The URI specified for Powershell remoting for Outlook Live is

When my application attempts to connect to Outlook Live by creating its
runspace and passing the WSManConnectionInfo instance with that URI, an
instance of PSRemotingTransportRedirectionException is thrown, the result
indicates that the URI needs to be changed as it has been redirected to
another address.

What is the expected way in which an application should deal with a
redirection? Is there another means by which an application can determine
where to redirect to, prior to opening the connection, or is the recommended
option to trap this exception and use the returned URI property
(RedirectLocation) to retry the connection?

was unhandled
Message=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.


Previous Posts In This Thread:

Submitted via EggHeadCafe - Software Developer Portal of Choice
Free Online Courses Available for Users