O'Reilly logo

SQL Server 2012 with PowerShell V3 Cookbook by Donabel Santos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Starting/stopping SQL Server services

This recipe describes how to start and/or stop SQL Server services.

Getting ready

Check which SQL services are installed in your machine. Go to Start | Run and type Services.msc. You should see a screen similar to this:

Getting ready

How to do it...

Let's look at the steps to toggle states for your SQL Server services:

  1. Open the PowerShell console by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
  2. Add the following code. Note that this code will work in both PowerShell V2 and V3:
    $Verbosepreference = "Continue" $services = @("SQLBrowser", "ReportServer") $hostName = "KERRIGAN" $services | ForEach-Object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required