PowerShell – CHECK, START and STOP SQL Services of a remote servers

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()}

 

About Prashanth Jayaram

DB Technologist, Author, Blogger, Service Delivery Manager at CTS, Automation Expert, Technet WIKI Ninja, MVB and Powershell Geek My Profile: https://social.technet.microsoft.com/profile/prashanth jayaram/ http://www.sqlshack.com/author/prashanth/ http://codingsight.com/author/prashanthjayaram/ https://www.red-gate.com/simple-talk/author/prashanthjayaram/ http://www.sqlservercentral.com/blogs/powersql-by-prashanth-jayaram/ Connect Me: Twitter @prashantjayaram GMAIL powershellsql@gmail.com The articles are published in: http://www.ssas-info.com/analysis-services-articles/ http://db-pub.com/ http://www.sswug.org/sswugresearch/community/
This entry was posted in PowerShell. Bookmark the permalink.

5 Responses to PowerShell – CHECK, START and STOP SQL Services of a remote servers

  1. Christiaan says:

    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?

    Like

  2. Hi there sir Prashanth. is there a powershell script that able to restart SQL Service (not sql agent) automatically?

    Like

  3. Pingback: Powershellscript for start and stop sql related services – SQL Hopes

Leave a comment