This project is read-only.

Command running problem

Sep 17, 2014 at 10:41 AM
Edited Sep 17, 2014 at 10:42 AM
I want to use ssh library to connect to windows server and fire command on Power Shell. My code is as follows
    ConnectionInfo connectionInfo = new PasswordConnectionInfo("ip",port, "id", "password");
    using (Renci.SshNet.SshClient client = new Renci.SshNet.SshClient(connectionInfo))
    {           
            client.Connect();
            var output = new MemoryStream();
            var shell = client.CreateShell(Encoding.ASCII, "Get-Service | Out-String", output, output);

            shell.Start();

            byte[] tempBytes = new byte[output.Length];
            output.Read(tempBytes, 0, tempBytes.Length);

            System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
            string result = enc.GetString(tempBytes);

            lbl.Text = "Output: " + result;

            shell.Stop();
            output.Close();
            output.Flush();
            output.Dispose();
     }
It is neither generating any error nor it does display anything in output. Can anybody help me out please..