How to find service start type in PowerShell V4 and V5

If you have used Get-Service in PowerShell V4, V3, V2 to find the status of a service or to restart a service you may have noticed that the get-service cmdlet does not show you the start type type (Auto, Manual, Disabled). If you run just Get-Service you  will get the following

services

As you can see the only information display is Status, Name and DisplayName. You can get more information if you run the following cmdlet Get-Service | format-list *  you will get all the information that the cmdlet gives you

services1.jpg

If you run Get-Service -name VSS | get-member you will see that start type method is not part of the cmdlet

services2.jpg

So in order  to find the start type on PowerShell V4 or before you can use Get-Ciminstance cmdlet. If you run the following cmdlet it will  show start type

Get-CimInstance Win32_Service

services3

Lets say you want to get all the services that start type is Manual. You can use the where-object along with Get-CimInstance

Get-CimInstance Win32_Service | Where-Object {$_.StartMode -eq ‘Manual’}

services4

Now if you want to start  all this service you can pipe the name to start-service

Capture3.PNG

Get-CimInstance Win32_Service | Where-Object {$_.StartMode -eq ‘Manual’} | Select-Object Name | Start-Service

Now let me give you a reason why you want to use PowerShell 5 If you run Get-service | format-list *, you will get the start type o this cmdlet now

Capture4

As you see StartType is part of the cmdlet now. If you want to get all the startType  = manual you will run the following

Get-Service | Where-Object { $_.StartType -eq ‘Manual’}

Capture5.PNG

 

If you dont trust the information on the screen you can add to the display the startType as  a column

Get-Service | Where-Object { $_.StartType -eq ‘Manual’} | Select-Object status, name, StartType

Capture6

 

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s