SQL Server - Working with Windows Services Examples and Powershell

05 January,2013 by Jack Vamvas

Question : How do you stop and start Windows Services   with Powershell?

Answer: Working with Windows services and Powershell is easy using the cmdlets : Get-Service ,Stop-Service,Start-Service,Restart-Service

The examples show two different approaches to stopping and starting Windows Services. The long way and the short way.

 

--check the service status 
$svc = Get-Service ‘SQLAgent$MyInst1’
$svc.status


--The long way 
$svc = Get-Service ‘SQLAgent$MyInst1’
$svc.Stop()
$svc.Start()


--The short way 

Stop-Service 'SQLAgent$MyInst1'
Start-Service 'SQLAgent$MyInst1'

--Restart the service

Restart-Service 'SQLAgent$MyInst1'

 Read More

SQL Server - SQL Server Restart with Powershell - SQL Server DBA

Powershell Scripts

 


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on SQL Server - Working with Windows Services Examples and Powershell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer