title: How do I execute the PowerShell command `open-device` from C#?
body: <p>I am using  <code>open-device 127.0.0.1</code> to connect a remote device. How do I invoke this from C#? This code:</p>
  
  <pre><code>PowerShell powerShell = PowerShell.Create(); 
  PSCommand connect = new PSCommand();
  connect.AddCommand("open-device");
  powerShell.Commands = connect;
  PSOutput = powerShell.Invoke()
  </code></pre>
  
  <p>results in the error:</p>
  
  <blockquote>
    <p><em><code>System.Management.Automation.CommandNotFoundException</code>: The term <code>open-device</code> is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</em> <code>at</code></p>
    
    <pre class="lang-none prettyprint-override"><code> System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at
   System.Management.Automation.Runspaces.Pipeline.Invoke() at
   System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspa‌​ce rs, Boolean performSyncInvoke)
  </code></pre>
  </blockquote>
  
  <p>However, I am able to run the <code>get-service</code> command using <code>Invoke</code>.</p>