c# powershell for exchange RRS feed

  • Question

  • Hi, I really need help with this one. I have been trying to figure out on how to fix the "" issue but could notfind the true error message.

    SecureString securePassword = new SecureString();
                foreach (char c in password) { securePassword.AppendChar(c); }
                PSCredential credential = new PSCredential(userName, securePassword);

                WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri(exchangeURL), exchangeSchema, credential);
                Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
                connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
                PowerShell powershell = PowerShell.Create();

                PSCommand command = new PSCommand();
                //PipelineReader<object> errors;
                powershell.Commands = command;

                    powershell.Runspace = runspace;
                    Collection<PSObject> results = powershell.Invoke();
                catch (Exception exception)
                    if (exception is System.Management.Automation.Remoting.PSRemotingTransportException)
                        switch (((System.Management.Automation.Remoting.PSRemotingTransportException)exception).ErrorCode)
                            case 5:  //process password issue
                            case -2144108526: //Process URL issue
                            default:// process other errors

    This is the similar example that I tried to follow.

    Here is the error message code that I got which I don't know.

    Connecting to remote server failed with the following error message : The WS-Management service does not support the request. For more information, see the about_Remote_Troubleshooting Help topic.
    System.Management.Automation.RuntimeException {System.Management.Automation.Remoting.PSRemotingTransportException}
    ErrorCode    -2144108428    int

    Friday, June 21, 2013 3:18 PM

All replies