Author | Klaas Vandenberghe (@PowerDbaKlaas) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Get-DbaService on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaService.
Gets the SQL Server related services on a computer.
Gets the SQL Server related services on one or more computers.
Requires Local Admin rights on destination computer(s).
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>]
PS C:\> Get-DbaService -ComputerName sqlserver2014a
Gets the SQL Server related services on computer sqlserver2014a.
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
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.
PS C:\> Get-DbaService -ComputerName sql1,sql2 -InstanceName MSSQLSERVER
Gets the SQL Server related services related to the default instance MSSQLSERVER on computers sql1 and sql2.
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.
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.
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.
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'.
PS C:\> (Get-DbaService -ComputerName sql1 -Type Engine).Restart($true)
Calls a Restart method for each Engine service on computer sql1.
The target computer(s).
Alias | cn,host,Server |
Required | False |
Pipeline | true (ByValue) |
Default Value | $env:COMPUTERNAME |
Only returns services that belong to the specific instances on all target computers.
Alias | Instance |
Required | False |
Pipeline | false |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Credential object used to connect to the computer as a different user.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Use -Type to collect only services of the desired SqlServiceType.
Can be one of the following: "Agent", "Browser", "Engine", "FullText", "SSAS", "SSIS", "SSRS", "PolyBase", "Launchpad"
Alias | |
Required | False |
Pipeline | false |
Default Value | |
Accepted Values | Agent,Browser,Engine,FullText,SSAS,SSIS,SSRS,PolyBase,Launchpad |
Can be used to specify service names explicitly, without looking for service types/instances.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Collect additional properties from the SqlServiceAdvancedProperty Namespace
This collects information about Version, Service Pack Level", SkuName, Clustered status and the Cluster Service Name
This adds additional overhead to the command.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |