Start Windows Services using PowerShell

I start and stop services on my workstation every now and then for testing purposes (well, primarily to stop services I do not use to minimize surface area and free up available resources which are not being used). What I used to do was to run a NET START command listing all the services that are started and piping it to a text file. Next, I’d insert a NET STOP on each line in the list to call the NET STOP command stopping that particular service. Unfortunately, there are cases where I wanted to start a specific service that start with a specific name. An example of this is starting the SQL Server instances running on my laptop. I have like 4 instances which are SQL Server versions ranging from 2000 to 20008. Now, I happen to memorize the instance names of those SQL Server instances, making it easy for me to just run a NET STOP servicename. Although it would be rather easy, imagine doing that on a server with like 9 instances (not to mention memorizing the instance names). I wouldn’t want to type the NET STOP command 9 times. Enter PowerShell

Here’s a PowerShell script to start all SQL Server instances on the local computer. You can modify the parameters if you want to suit your needs. I’ve used this to start all the services related to Symantec on my machine as well

Get-Service | where {$_.Name -like "MSSQL$*"} | Start-Service

(NOTE: There’s a pipe character “” between Get-Service cmdlet and Where and before the Start-Service cmdlet. In case it does not display here)

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published.