# Install logstash as a service via Powershell

**URL:** <https://discuss.elastic.co/t/install-logstash-as-a-service-via-powershell/34900>\
**Category:** Logstash\
**Created:** [November 18, 2015, 8:49am UTC](https://discuss.elastic.co/t/install-logstash-as-a-service-via-powershell/34900 "2015-11-18T08:49:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedrovac](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@pedrovac](https://discuss.elastic.co/u/pedrovac)\
**Post date:** [November 18, 2015, 8:49am UTC](https://discuss.elastic.co/t/install-logstash-as-a-service-via-powershell/34900/1 "2015-11-18T08:49:16Z")

</div>

Hello. I have a problem. I'm trying to install Logstash as a service in Windows OS via Powershell.  
I have run.bat file to start logstash:

> logstash.bat agent -f logstash.conf

My PS command looks like:

> New-Service -Name Logstash -BinaryPathName "C:\Windows\system32\cmd.exe /c C:\ELK\logstash\bin\run.bat" -DisplayName "Logstash" -Description "Test Logstash service".

But services.msc throws an error 1053. But if I use NSSM for that I have no errors and everything is ok. How to fix that?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 18, 2015, 8:53pm UTC](https://discuss.elastic.co/t/install-logstash-as-a-service-via-powershell/34900/2 "2015-11-18T20:53:25Z")

</div>

Where did you get the PS script from?

---

<div class="post-metadata">

**Author:** ![pedrovac](https://avatars.discourse-cdn.com/v4/letter/p/fbc32d/32.png) [@pedrovac](https://discuss.elastic.co/u/pedrovac)\
**Post date:** [November 19, 2015, 1:05am UTC](https://discuss.elastic.co/t/install-logstash-as-a-service-via-powershell/34900/3 "2015-11-19T01:05:34Z")

</div>

@warkolm I have written it based on Microsoft's documentation about PowerShell New-Service function. [https://technet.microsoft.com/en-us/library/hh849830.aspx](https://technet.microsoft.com/en-us/library/hh849830.aspx)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:22am UTC](https://discuss.elastic.co/t/install-logstash-as-a-service-via-powershell/34900/4 "2017-07-06T05:22:17Z")

</div>

Closed on July 6, 2017, 5:22am UTC


