Reputation: 127
I am trying to run a PowerShell command from within C#.
This is the code
PSCredential Credential = new PSCredential("domain.inet\adminuser", domainAdminPswrd);
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(
new Uri("http://exchangeserver/powershell?serializationLevel=Full"),
"http://schemas.microsoft.com/powershell/Microsoft.Exchange", Credential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
PowerShell powershell = PowerShell.Create();
When I run the above code, the compiler halts at 'Runspace runspace' (second to last line) with the following error:
An unhandled exception of type 'System.InvalidProgramException' occurred
Additional information: Common Language Runtime detected an invalid program.
I have been trying to troubleshoot, but have had no luck so far.
Upvotes: 0
Views: 827
Reputation: 127
I resolved this issue by installing KB2819745 on the machine running the c# program. (not the server I am connecting to)
Upvotes: 3