Sometimes I need to start or restart a lot of services belonging to my application, all having the product / company name as prefix, and I would like to start it all, but not the ones that are flagged as Manual.
To simple start all the services that match a prefix you would do something like this:
Start-Service "MyProduct*"
but when you need to start the service that are not flagged as Manual startup, there’s no command/filter directly in powershell command, but you need to use Wmi objects in this way:
Get-WmiObject win32_service | where { $_.Name -like "MyProduct*" -and $_.StartMode -ne "Manual" } | Start-Service
With the same syntax you can of course, do Get-Service, Stop-Service, and all the other related commands.
—————–
UPDATE 16/03/2015
—————–
A BETTER WAY FOR WIN >= 2012!
Starting from Powershell 3.0 you can use the Get-CimInstance Win32_Service command, where CIM is a new common interface to access windows and non-windows OS, created to focus the new cloud oriented systems. CIM is also performing better than WMI.
Get-CimInstance Win32_Service -Filter "Name like 'MyProduct%' AND StartMode != 'Manual'" | Start-Service
Here I’m using -Filter instead of Where-Object, just because the first usually performs better.