deviceZero

PSRemotingTransportRedirectException Error

I spent way too much time trying to use PowerShell WinRM to connect to Outlook Live this week. Here is my basic connection code:

public void ConnectToOutlookLive()
{
string username = "user@domain.com";
string password = "plaintextpassword";

string uri = "https://ps.outlook.com/powershell/";
string schema = "http://schemas.microsoft.com/powershell/Microsoft.Exchange";

SecureString securePassword = new SecureString();

foreach (char c in password.ToCharArray())
securePassword.AppendChar(c);

PSCredential psc = new PSCredential(username, securePassword);

WSManConnectionInfo rri = new WSManConnectionInfo(new Uri(uri), schema, psc);

rri.AuthenticationMechanism = AuthenticationMechanism.Basic;
//rri.AuthenticationMechanism = AuthenticationMechanism.Kerberos;

Runspace remoteRunspace = RunspaceFactory.CreateRunspace(rri);
remoteRunspace.Open(); //Error happens when trying to open the connection
}

When using AuthenticationMechanism.Kerberos I received the following error:

System.Management.Automation.Remoting.PSRemotingTransportException was caught
Message=Connecting to remote server failed with the following error message : Logon failure: unknown user name or bad password. For more information, see the about_Remote_Troubleshooting Help topic.
Source=System.Management.Automation
WasThrownFromThrowStatement=false
ErrorCode=1326
TransportMessage=Logon failure: unknown user name or bad password.

When using AuthenticationMechanism.Basic I received a different error:

System.Management.Automation.Remoting.PSRemotingTransportRedirectException was caught
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.

Exception when opening a Remote Runspace using WSManConnectionInfo – This was the only place on the whole internet I could find someone who was having the same problem… unfortunately the solution did not fix my issue.

Solution

The exception is being thrown because the remote server is redirecting you to a new location. So you have to set the MaximumConnectionRedirectionCount. Just add the following line of code before the open and everything works fine:

rri.MaximumConnectionRedirectionCount = 1;

I hope this saves someone a lot of time and frustration.

Game Dev Blog

I am starting a new blog focused on game development. You can find it here:
http://gamedev.devicezero.com/.

Sadie Decorates for Christmas

Oracle Version Error

Last night, I struggled with the following error for a few hours:

Could not load file or assembly ‘Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342′ or one of its dependencies. The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly ‘Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342′ or one of its dependencies. The system cannot find the file specified.

Development Machine Setup:
Windows 7 64 bit
Oracle 11g Release 1 (11.1.0.7.0)

Target Machine Setup:
Windows XP 32 bit
Originally Oracle 10g, now Oracle 11g (11.1.0.6.0)

After many grueling hours of searching the darkest corners of the internet, I found this post: ODP.NET & LLBLGen Pro. The author suggests using a binding redirect to fix a problem with LLBLGen Pro (but same basic error). While I am not exactly sure what is causing my problem, adding a binding redirect fixed it. The solution seems silly. I install Oracle 11g release 1 (11.1.0.7.0), which is what it is asking for and it still cannot be found.
I install Oracle 11g (11.1.0.6.0) and add the binding redirect and it works.

Here is my config:

<assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″>
<dependentAssembly>
<assemblyIdentity name=”Oracle.DataAccess” publicKeyToken=”89B483F429C47342″/>
<bindingRedirect oldVersion=”2.111.7.20″ newVersion=”2.111.6.0″/>
</dependentAssembly>
</assemblyBinding>

Note: Assembly redirection can work both ways. You can re-direct calls to a new version of the to an older installed version and vice-versa. You can read more about Binding Redirects on MSDN.

I hope this post can save someone a few headaches.

Database Normalization explained

Lost Tooth


My son lost his first tooth day!

Photo taken 8/31/2009

Storm Trooper Sadie

Dad 2.0

Someone must have upgraded my Father. Not only has he joined Facebook, but he started a writing blog about his childhood. Go read his first story. Great stuff. Welcome to the internet Dad.

Peanut Butter Hairball

The following is a chat conversation I had with my wife today:

Susan: oh dear
Bubby ate hairy peanut butter

Edward: yuuuck

Susan: Lauren sent him to the toilet to throw up

Edward: lol

Susan: she is instructing him to make sure he flushes

Edward: for real?

Susan: yes
dead serious

Edward: does he want to throw up?

Susan: apparently he dropped his peanut butter spoon and decided it was okay and he ate it except their was a hair on it.
so Bubby starts gagging
Lauren sends him to the bathroom
Bubby hacks around above the toilet
Lauren turns on the exhaust fan because she doesn’t want the bathroom to smell of peanut butter
i was messaging you and i hear Bubby from the bathroom yell “i got it!”
apparently your son is part cat and can hack up a hairball
cause i went into the bathroom and see the infamous hair on his fingers
he had indeed hacked it up
he washes his hands and gives Lauren a big hug yelling thank you
apparently her advice was just the ticket when you want to hack up a hairball
the only downside Lauren is convinced she smells like peanut butter now and can’t stand it

Kids… you gotta love them!

Little Rock Climber

Wisdom of a 5 year old

Sunday, my son showed me his craft from Children’s church, a simple paper with the word “God” and a colorful star. “It a Mario star!” he informed me, “Because we should serve God and Mario!”

Amen.