This article gives PowerShell script to restart the SQL Server service, SQL Server Agent, Reporting Service (SSRS), and SQL Server Integration Services 15.0.
Take the script from GitHub and execute it in the Windows PowerShell IDE.
If you want to create a batch file, save the PS file as RestartSQLServices.ps1 in the C:\SQL directory.
Launch notepad and copy-paste the following code.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:\SQL\RestartSQLServices.ps1""' -Verb RunAs}"
Save the file as SQLServiceRestart.bat. The batch script looks like below.
You can double-click on the batch file, and it restarts the SQL Services.
Comments