Reputation: 13
The following command works as I expect it:
Get-Service | Where-Object {$_.status -eq 'running'}
However this one does not:
Get-Service | Where-Object {$_.startmode -eq 'manual'}
Could anyone explain why that is? How do I sort services based on their start up type?
Upvotes: 1
Views: 220
Reputation: 389
I think it's as simple as accessing the correct property. Get-Service returns an array of ServiceController
objects. The property you're looking for is called StartType
. So
Get-Service | Where-Object {$_.Starttype -eq 'Manual'}
should get you what you're looking for.
If you ever need to look at all the properties and methods of a given object you can always pipe it to Get-Member
.
So in this instance you could so something like
Get-Service | select -First 1 | Get-Member
This is getting the first instance of the ServiceController from the list and showing you all the member properties and methods.
Also, if you're just getting started I would recommend jumping on a book or blog series that will give you a good foundation so you don't spend too much time banging your head. Learn Windows PowerShell in a Month Lunches is great for a sysadmin learning powershell.
Upvotes: 1