dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Restart-DbaSqlService

Restarts the SQL Server related services on one or more computers. Will follow SQL Server service dependencies.

Requires Local Admin rights on destination computer(s).

Screenshots

dbatools - Restart-DbaSqlService

Examples

Restarts the SQL Server related services on computer sqlserver2014a.

Restart-DbaSqlService -ComputerName sqlserver2014a

Gets the SQL Server related services on computers sql1, sql2 and sql3 and restarts them.

‘sql1′,’sql2’,’sql3’| Get-DbaSqlService | Restart-DbaSqlService

Restarts the SQL Server services related to the default instance MSSQLSERVER on computers sql1 and sql2.

Restart-DbaSqlService -ComputerName sql1,sql2 -Instance MSSQLSERVER

Restarts the SQL Server related services of type “SSRS” (Reporting Services) on computers in the variable MyServers.

Restart-DbaSqlService -ComputerName $MyServers -Type SSRS

Restarts SQL Server database engine services on sql1 forcing dependent SQL Server Agent services to restart as well.

Restart-DbaSqlService -ComputerName sql1 -Type Engine -Force

Author

This command was created by Kirill Kravtsov. You can find Kirill on Twitter.

Get-Help

From PowerShell, execute Get-Help Restart-DbaSqlService -Detailed for more information on this function.

Source Code

Want to see the source code? View Restart-DbaSqlService.ps1 on GitHub
 

Related commands