You can use below script to start and stop remote SQL services.
* Just for one computer
(Get-Service -ComputerName YOURCOMPUTERNAME -Name 'SQLAgent').Stop()
(Get-Service -ComputerName YOURCOMPUTERNAME -Name 'SQLAgent').Start()
* For multiple computer
$ServerList = Get-Content "DRIVE\ServerNames.txt"
ForEach ($ServerName in $ServerList)
{
Write-Host $ServerName
(Get-Service -ComputerName YOURCOMPUTERNAME -Name 'SQLAgent').Stop()
(Get-Service -ComputerName YOURCOMPUTERNAME -Name 'SQLAgent').Start()
}
No comments:
Post a Comment