title: PowerShell run from C# to start/stop IIS application pools has no effect
body: <p>I'm stuck on this little piece of code for two days now. I have a C# helper class to execute PowerShell scripts. I basically use <code>PowerShell.Create()</code> to initialize an instance of PowerShell, then use <code>AddScript</code> to write the commands, and then call the <code>Invoke</code> method synchronously. </p>
  
  <p>Now I'm trying to stop a windows service and an IIS application pool. The Windows service stops, but no effect on IIS application pool.</p>
  
  <pre><code>using (var powerShell = PowerShell.Create())
  {
      // PowerShell doesn't stop application pool
      powerShell.AddScript("Stop-WebAppPool -Name application_name");
  
      // But it stops windows service
      powerShell.AddScript("Stop-Service service_name");
  
      var result = powerShell.Invoke();
  }
  </code></pre>
  
  <p>Both scripts work when I execute them via ISE. What is the problem? I think I'm missing something about PowerShell.</p>