From: guy on
Hi,

You can catch the exception and redirect to the right URL

try
{
WSManConnectionInfo connInfo = new WSManConnectionInfo(..);
rs = RunspaceFactory.CreateRunspace(connInfo);
rs.Open();
}
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.

Guy.



NZSchoolTech wrote:

PSRemotingTransportRedirectException exception thrown with WSManConnectionInfo
02-May-10

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
https://ps.outlook.com/powershell/

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?

System.Management.Automation.Remoting.PSRemotingTransportRedirectException
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 Eggheadcafe.com Users
http://www.eggheadcafe.com/tutorials/aspnet/5261083e-6e03-4b25-8728-fc3cf6855293/free-online-courses-avail.aspx