PowerShell.Invoke() doesn't execute anything
<p>I'm writing a c# application that is supposed to execute remote commands using PowerShell. I read a lot of examples, and this is how I'm doing it:</p>

<pre><code>var command = "\"cmd.exe /C dir C:\\ &gt; C:\\dir.log\"";
const string shellUri = @"http://schemas.microsoft.com/powershell/Microsoft.PowerShell";
var credentials = new PSCredential("username", "password".GetSecureString());
var connection = new WSManConnectionInfo(false, "serverName" , 5985, "/wsman", shellUri,credentials);
connection.AuthenticationMechanism = AuthenticationMechanism.Default;
var runspace = RunspaceFactory.CreateRunspace(connection);
runspace.Open();
using (var powershell = PowerShell.Create())
{
    powershell.Runspace = runspace;
    powershell.AddScript(command);
    var results = powershell.Invoke();
}
</code></pre>

<p>The problem I'm facing is that everything seems to execute (codewise) just fine, I'm gettnig the result object, but the actual cmd command is not executing.
Any thoughts?</p>