title: Error when running powershell command remotely
body: <p>I want to run Powershell command on remote machine. This is method that I am using (localhost:131 is because I use tunnel to remote machine's port 5985):</p>
  
  <pre><code>  public string RunRemotePowerShellCommand(string command)
      {
             System.Security.SecureString password = new System.Security.SecureString();
              foreach (char c in _password.ToCharArray())
              {
                  password.AppendChar(c);
              }
  
              string schema = "http://schemas.microsoft.com/powershell/Microsoft.Powershell";
  
              WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false,
                  "localhost", 131, "/wsman", schema, new PSCredential(_domain + @"\" + _userName, password));
  
              using (Runspace remoteRunspace = RunspaceFactory.CreateRunspace(connectionInfo))
              {
                  remoteRunspace.Open();
                  using (PowerShell powershell = PowerShell.Create())
                  {
                      powershell.Runspace = remoteRunspace;
                      powershell.AddCommand(command);
                      powershell.Invoke();
  
                      Collection&lt;PSObject&gt; results = powershell.Invoke();
  
                      // convert the script result into a single string
                      StringBuilder stringBuilder = new StringBuilder();
                      foreach (PSObject obj in results)
                      {
                          stringBuilder.AppendLine(obj.ToString());
                      }
                      return stringBuilder.ToString();
                  }
              }
      }
  </code></pre>
  
  <p>I'm trying to run following command: </p>
  
  <pre><code>D:\FolderName\scriptName.ps1 -action editbinding -component "comp1","comp2","comp3","comp4"
  </code></pre>
  
  <p>Like this:</p>
  
  <pre><code>RunRemotePowerShellCommand(@"D:\FolderName\scriptName.ps1 -action editbinding -component ""comp1"",""comp2"",""comp3"",""comp4""");
  </code></pre>
  
  <p>but I get: </p>
  
  <pre><code>Error: System.Management.Automation.RemoteException: The term 'D:\FolderName\scriptName.ps1 -action editbinding -component "comp1","comp2","comp3","comp4"' is not recognized as a name of cmdlet, function, script file, or operable program. Check the spelling of the name, or if the path is included, verify that the path is correct and try again.
  </code></pre>
  
  <p>The method works fine with simple commands, and the command that I want to run is ok when I run it on remote machine.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Regards,
   Dusan</p>