title: Whats the difference between powershell's Stop-Service and NET-STOP
body: <p>In powershell, I've seen multiple ways to stop a service</p>
  
  <p>The more modern way</p>
  
  <pre><code>Stop-Service wuauserv
  </code></pre>
  
  <p>And the more legacy way</p>
  
  <pre><code>NET STOP WUAUSERV
  </code></pre>
  
  <p>The legacy way <a href="https://stackoverflow.com/questions/47403834/powershell-ignore-error">is much more difficult to automate because it is not natively idempotent.</a></p>
  
  <p>I have powershell scripts that builds a windows golden images using packer. Initially the scripts used <code>NET STOP</code>. I found once I switched to <code>Stop-Service</code>, I seemed to get more frequent failures when rebooting a VM after installing windows updates.</p>
  
  <p>Do both <code>Stop-Service</code> and <code>NET STOP</code> produce the same result? Or are there differences between them that might explain why the legacy one seems more reliable? </p>