Problem when opening a runspace in a web application RRS feed

  • Question

  • Hello,

    I try to debug this code to run commands on a remote Exchange 2010 server (Windows server 2008 R2, host in a VMWare) from my client

    Uri uriPs = new Uri("http://" + server + "/powershell");
    string shellUri = "http://schemas.microsoft.com/powershell/Microsoft.Exchange";
    SecureString secure = new SecureString();
    foreach (char c in password)
    PSCredential credential = new PSCredential(username, secure);
    WSManConnectionInfo connPs = new WSManConnectionInfo(uriPs, shellUri, credential);
    connPs.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
    Runspace runspace = RunspaceFactory.CreateRunspace(connPs);
    PowerShell powershell = PowerShell.Create();
    powershell.Runspace = runspace;

    When i run this code in a Console Application... it works! Yeaha...

    But, when i run it in a Asp Mvc application, i have an error:

    Processing data for a remote command failed with the following error message: <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="3762507597" Machine="server"><f:Message><f:ProviderFault provider="PowerShellplugin" path="%windir%\system32\pwrshplugin.dll"></f:ProviderFault></f:Message></f:WSManFault> For more information, see the about_Remote_Troubleshooting Help topic

    I am almost desperate to find a solution. Any help of any kind will be welcome.

    Thank you in advance.

    Monday, January 27, 2014 9:29 AM