Startup type of Windows Service

To retreive the startup type of a Windows Service, use this:

When using Powershell version 4 and earlier, the property StartType is not populated, so you need to query Wmi:

To change the startup type to Automatic: