Discovering SQL Server services
In this recipe, we enumerate all SQL Server services and list their status.
Getting ready
Check which SQL Server services are installed in your instance. Go to Start | Run and type services.msc
. You should see a screen similar to this:
How to do it...
Let's assume you are running this script on the server box.
Open the PowerShell console by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Add the following code and execute it:
Import-Module SQLPS #replace KERRIGAN with your instance name $instanceName = "KERRIGAN" $managedComputer = New-Object 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' $instanceName #list services $managedComputer.Services | Select Name, Type, Status, DisplayName | Format-Table -AutoSize
Your result will look similar to the one shown in the following screenshot:
Items listed on your screen will vary depending on the features installed and running in your instance.
Confirm that these are the services...