PSRemotingTransportRedirectException exception thrown with WSManConnectionInfo

N

NZSchoolTech

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.

--
 
G

guy t

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 t
a remote Powershell session for Exchange 2010 (Outlook Live) by specifyin
the URI in an instance of WSManConnectionInfo

The URI specified for Powershell remoting for Outlook Live i
https://ps.outlook.com/powershell

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

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

System.Management.Automation.Remoting.PSRemotingTransportRedirectExceptio
was unhandle
Message=The WinRM service cannot process the request because the reques
needs to be sent to a different machine. Use the redirect information t
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/tutorial...8-fc3cf6855293/free-online-courses-avail.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top