In this recipe, we will enumerate all SQL Server services and list their statuses.
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:
Let's assume you are running this script on the server box:
Open PowerShell ISE as administrator.
Add the following code and execute:
Import-Module SQLPS -DisableNameChecking #you can replace localhost with your instance name $instanceName = "localhost" $managedComputer = New-Object Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer $instanceName #list services $managedComputer.Services | Select-Object Name, Type, ServiceState, DisplayName | Format-Table -AutoSize
Your result will look similar to the one shown in the following screenshot:
Items listed in your screen will vary depending on the features installed and running in your instance
Confirm that these are the services that exist in your server. Check...