title: How to setup automatic startup configuration for a windows service using Powershell DSC
body: <p>I am building a windows server image using <a href="https://www.packer.io/" rel="nofollow noreferrer">Packer</a> tool and <a href="https://docs.microsoft.com/en-us/powershell/scripting/dsc/overview/overview?view=powershell-7.1" rel="nofollow noreferrer">Powershell DSC</a>. In my DSC script I am installing and starting the tomcat service as below,</p>
  <pre><code>Script Tomcat_Service_Install
          {
              TestScript = { $false }
              GetScript = { $null }
              SetScript = { Start-Process &quot;C:\Program Files\apache-tomcat-X.X.XX\bin\service.bat&quot; -ArgumentList &quot;install&quot; -WorkingDirectory &quot;C:\Program Files\apache-tomcat-X.X.XX\bin&quot; -Wait}
          }
  Script Tomcat_Service_Start
          {
              TestScript = { $false }
              GetScript = { $null }
              SetScript = { Start-Process &quot;C:\Program Files\apache-tomcat-X.X.XX\bin\tomcatX.exe&quot; -ArgumentList &quot;start&quot; -WorkingDirectory &quot;C:\Program Files\apache-tomcat-X.X.XX\bin&quot; -Wait}
              DependsOn = &quot;[Script]Tomcat_Service_Install&quot;
          }
  </code></pre>
  <p>After the build completes, I logged into the system to check all the configurations. I found out that the tomcat service was installed on the system as a windows services but it was not running and the startup type was set to Manual.</p>
  <p>Is there any way I could set the Startup type to Automatic for tomcat service using Powershell?</p>