title: Starting and Stopping Services with Puppet
body: <p>I want to stop a service, execute a Powershell script and then start the service again using Puppet. The code below does not work because <code>My Service</code> is defined twice.</p>
  
  <pre><code>service { 'My Service':
      ensure  =&gt; 'stopped',
      require =&gt; Package['Install Go Agent']
  }
  exec { 'Do Stuff':
      command   =&gt; '...',
      provider  =&gt; powershell,
      require   =&gt; Service['Go Agent']
  }
  service { 'My Service':
      ensure  =&gt; 'started',
      require =&gt; Exec['Install Go Agent']
  }
  </code></pre>
  
  <p>In essence my Powershell script is setting the windows service username and password which sadly, you cannot do using Puppet.</p>