Install a Windows Service with PowerShell

Here is a snippet of code that you can use to install a Windows Service using PowerShell:

new-service -Name [INSERT SERVICE NAME] -DisplayName "[INSERT DISPLAY NAME]" -Description "[INSERT DESCRIPTION]" -BinaryPathName "[INSERT BINARY PATH]" -StartupType Manual -Credential [INSERT CREDENTIALS]

Here is an example for a pretend service:

new-service -Name Jonathan.Welch.Test.Service -DisplayName "Jonathan Welch Test Service" -Description "Test Service that does some stuff" -BinaryPathName "C:\Jon\Jonathan.Welch.Test.Service.exe" -StartupType Manual -Credential JonDomain\Jon.Welch

To install a service with startup type Automatic just change -StartupType Manual to be -StartupType Automatic as shown below:

new-service -Name Jonathan.Welch.Test.Service -DisplayName "Jonathan Welch Test Service" -Description "Test Service that does some stuff" -BinaryPathName "C:\Jon\Jonathan.Welch.Test.Service.exe" -StartupType Automatic -Credential JonDomain\Jon.Welch