Replace a valid server name in the following examples. Try to do a testing on your local machine and understand before you execute it on any Production Server.
Example 1: Find all SQL related services on HQSQ001
Get-Service -ComputerName HQSQ001 | ?{$_.Displayname -like “*SQL*“}|select name,Displayname,status
Example 2: Find all SQL related services on multiple servers[Separate the server name by comma]
Get-Service -ComputerName HQSQ001,HQSQ002 | ?{$_.Displayname -like “*SQL*“}|select name,Displayname,status
Example 3: Stop only SQL REPORTING Services on both the server
Get-Service -ComputerName HQSQ001,HQSQ002 | ?{$_.Displayname -match “SQL SERVER REPORT”}|%{$_.stop()}
Example 4: Start only SQL REPORTING Services on both the server
Get-Service -ComputerName HQSQ001,HQSQ002 | ?{$_.Displayname -match “SQL SERVER REPORT”}|%{$_.start()}
Hi. Is there a power shell script where i can check windows service status on multiple remote servers using a text or csv file to retrieve?
LikeLike
Christiaan,
You can take a look at the below post
–Prashanth
LikeLike
Hi there sir Prashanth. is there a powershell script that able to restart SQL Service (not sql agent) automatically?
LikeLike
Hi Hutasuhut Budi…
I’m little bit curious…May I know the background of this requirement. SQL agent is an dependent service of SQL Service.
If you stop the main services, the dependent services won’t work.
–Prashanth
LikeLike
Pingback: Powershellscript for start and stop sql related services – SQL Hopes