title: C# PowerShell create blank text file on desktop
body: <p>I'm trying to use PowerShell from C# to create a new file on desktop. In the terminal you would do:</p>
  
  <pre><code>cd desktop
  $null &gt;&gt; newfile.txt
  </code></pre>
  
  <p>So I'm trying to do this in C# to mimic the previous statements:</p>
  
  <pre><code>using (PowerShell PowerShellInstance = PowerShell.Create())
  {
    PowerShellInstance.AddScript("cd desktop; $null &gt;&gt; newfile.txt");
  
    PowerShellInstance.Invoke();
  }
  </code></pre>
  
  <p>This runs without any exceptions but the file isn't created on the desktop. Can anyone point out what I'm doing wrong with the <code>AddScript</code>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>It looks like the problem comes from using cd and then the create in sequence.</p>
  
  <p>I was able to get it working by doing</p>
  
  <pre><code>PowerShellInstance.AddScript("$null &gt;&gt; C:\\users\\me\\Desktop\\newfile.txt");
  </code></pre>
  
  <p>If anyone knows how to do a cd command followed by another please let me know.</p>