---
title: "Get-DbaService"
description: "Retrieves SQL Server-related Windows services from local or remote computers."
url: "https://dbatools.io/Get-DbaService/"
availability: "Windows only"
tags: ["Service", "SqlServer", "Instance", "Connect"]
author: "Klaas Vandenberghe (@PowerDbaKlaas)"
source: "https://github.com/dataplat/dbatools/blob/master/public/Get-DbaService.ps1"
last_updated: "2024-01-01"
---

# Get-DbaService

## Synopsis

Retrieves SQL Server-related Windows services from local or remote computers.

## Description

Retrieves detailed information about SQL Server-related Windows services across one or more computers, including Database Engine, SQL Agent, Reporting Services, Analysis Services, Integration Services, and other SQL Server components. This function replaces manual service management tasks by providing a unified view of service status, startup modes, and service accounts across your SQL Server environment.  
  
Particularly useful for inventory management, troubleshooting service issues, and performing bulk service operations across multiple servers. The function can filter by service type, instance name, or specific service names, and optionally includes advanced properties like SQL Server version and service pack levels.  
  
Returns service objects with built-in methods for common operations like Start(), Stop(), Restart(), and ChangeStartMode(), eliminating the need to use separate service management commands.  
  
Requires Local Admin rights on destination computer(s).

## Syntax

```powershell
Get-DbaService
    [[-ComputerName] <DbaInstanceParameter[]>]
    [-InstanceName <String[]>]
    [-SqlInstance <DbaInstanceParameter[]>]
    [-Credential <PSCredential>]
    [-Type <String[]>]
    [-AdvancedProperties]
    [-EnableException]
    [<CommonParameters>]

Get-DbaService
    [[-ComputerName] <DbaInstanceParameter[]>]
    [-Credential <PSCredential>]
    [-ServiceName <String[]>]
    [-AdvancedProperties]
    [-EnableException]
    [<CommonParameters>]

```

## Examples

### Example 1: Gets the SQL Server related services on computer sqlserver2014a

```powershell
PS C:\> Get-DbaService -ComputerName sqlserver2014a
```

### Example 2: Gets the SQL Server related services on computers sql1, sql2 and sql3

```powershell
PS C:\> 'sql1','sql2','sql3' | Get-DbaService -AdvancedProperties
```

Gets the SQL Server related services on computers sql1, sql2 and sql3. Includes Advanced Properties from the SqlServiceAdvancedProperty Namespace  

### Example 3: Gets the SQL Server related services on computers sql1 and sql2 via the user WindowsUser, and shows them in a...

```powershell
PS C:\> $cred = Get-Credential WindowsUser
PS C:\> Get-DbaService -ComputerName sql1,sql2 -Credential $cred  | Out-GridView
```

Gets the SQL Server related services on computers sql1 and sql2 via the user WindowsUser, and shows them in a grid view.  

### Example 4: Gets the SQL Server related services related to the default instance MSSQLSERVER on computers sql1 and sql2

```powershell
PS C:\> Get-DbaService -ComputerName sql1,sql2 -InstanceName MSSQLSERVER
```

### Example 5: Gets the SQL Server related services related to the default instance MSSQLSERVER on computers sql1, the named...

```powershell
PS C:\> Get-DbaService -SqlInstance sql1, sql1\test, sql2\test
```

Gets the SQL Server related services related to the default instance MSSQLSERVER on computers sql1, the named instances test on sql1 and sql2.  

### Example 6: Gets the SQL Server related services of type &quot;SSRS&quot; (Reporting Services) on computers in the variable...

```powershell
PS C:\> Get-DbaService -ComputerName $MyServers -Type SSRS
```

Gets the SQL Server related services of type "SSRS" (Reporting Services) on computers in the variable MyServers.  

### Example 7: Gets the SQL Server related services with ServiceName MSSQLSERVER or SQLSERVERAGENT for all the servers that...

```powershell
PS C:\> $MyServers =  Get-Content .\servers.txt
PS C:\> Get-DbaService -ComputerName $MyServers -ServiceName MSSQLSERVER,SQLSERVERAGENT
```

Gets the SQL Server related services with ServiceName MSSQLSERVER or SQLSERVERAGENT  for all the servers that are stored in the file. Every line in the file can only contain one hostname for a server.  

### Example 8: Gets the SQL Server related services of types Sql Agent and DB Engine on computer sql1 and changes their...

```powershell
PS C:\> $services = Get-DbaService -ComputerName sql1 -Type Agent,Engine
PS C:\> $services.ChangeStartMode('Manual')
```

Gets the SQL Server related services of types Sql Agent and DB Engine on computer sql1 and changes their startup mode to 'Manual'.  

### Example 9: Calls a Restart method for each Engine service on computer sql1

```powershell
PS C:\> (Get-DbaService -ComputerName sql1 -Type Engine).Restart($true)
```

### Optional Parameters

##### -ComputerName

Specifies the target computer(s) to retrieve SQL Server services from. Accepts computer names, IP addresses, or FQDN.  
Use this when you need to check service status across multiple servers in your environment.

| Property | Value |
| --- | --- |
| Alias | cn,host,Server |
| Required | False |
| Pipeline | true (ByValue) |
| Default Value | $env:COMPUTERNAME |

##### -InstanceName

Filters results to show only services belonging to the specified SQL Server instance names.  
Use this when you need to focus on specific instances rather than all SQL Server services on the target computers.

| Property | Value |
| --- | --- |
| Alias | Instance |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -SqlInstance

Use a combination of computername and instancename to get the SQL Server related services for specific instances on specific computers.  
Parameters ComputerName and InstanceName will be ignored if SqlInstance is used.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Credential

Credential object used to connect to the computer as a different user.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Type

Filters results to specific SQL Server service types such as Database Engine, SQL Agent, or Reporting Services.  
Use this when troubleshooting specific service types or performing targeted service management operations. Can be one of the following: "Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS",   
"SSRS", "PolyBase", "Launchpad", "PowerBI"

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |
| Accepted Values | Agent,Browser,Engine,FullText,SSAS,SSIS,SSRS,PolyBase,Launchpad,PowerBI |

##### -ServiceName

Specifies exact Windows service names to retrieve, bypassing automatic service discovery.  
Use this when you know the specific service names and want to avoid the overhead of scanning for all SQL Server services.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -AdvancedProperties

Includes additional service properties such as SQL Server version, service pack level, SKU name, and cluster information.  
Use this when you need detailed service information for inventory, compliance, or troubleshooting purposes. Note that this adds processing time to the command.  
This will also output the additional property SqlInstance based on the Clustered and VSName properties for engine services.  
Use this property to connect to the correct SQL instance.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.  
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.  
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

## Outputs

**Microsoft.SqlServer.Management.Smo.Wmi.SqlService**

Returns one service object per SQL Server-related Windows service found on the target computer(s). Each service object includes properties for service name, status, startup mode, and service account information.

**Default display properties (via Select-DefaultView):**

- ComputerName: The name of the computer hosting the service
- ServiceName: The Windows service name (e.g., MSSQLSERVER, SQLSERVERAGENT)
- ServiceType: The type of SQL Server service (Engine, Agent, FullText, SSIS, SSAS, SSRS, Browser, PolyBase, Launchpad, PowerBI, Unknown)
- InstanceName: The SQL Server instance name associated with the service
- DisplayName: The friendly display name of the service
- StartName: The user account under which the service runs
- State: The current state of the service (Stopped, Start Pending, Stop Pending, Running)
- StartMode: The startup mode of the service (Unknown, Automatic, Manual, Disabled)

**When -AdvancedProperties is specified, additional properties are included:**

- Version: The SQL Server version number of the service
- SPLevel: The service pack level installed on the service
- SkuName: The SQL Server edition/SKU name (e.g., Enterprise, Standard)
- Clustered: Boolean (as numeric or empty) indicating if the service is part of a cluster
- VSName: The virtual server name if the service is clustered
- SqlInstance: The full SQL instance name (including virtual server name if clustered) for engine services

**ScriptMethods (callable on returned objects):**

- Stop([bool]$Force): Stops the service, with optional force parameter
- Start(): Starts the service
- Restart([bool]$Force): Restarts the service, with optional force parameter
- ChangeStartMode([string]$Mode): Changes the startup mode (Automatic, Manual, Disabled)
All service objects support Get-Member to view additional properties from the underlying WMI SqlService class.

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
