< Back

Get-DbaService

Mon Jan 13, 2020 11:38 am

NAME Get-DbaService



SYNOPSIS

Gets the SQL Server related services on a computer.





SYNTAX

Get-DbaService [[-ComputerName] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [-InstanceName

<System.String[]>] [-Credential <Pscredential>] [-Type <System.String[]>] [-AdvancedProperties <Switch>]

[-EnableException <Switch>] [<CommonParameters>]



Get-DbaService [[-ComputerName] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [-Credential

<Pscredential>] [-ServiceName <System.String[]>] [-AdvancedProperties <Switch>] [-EnableException <Switch>]

[<CommonParameters>]





DESCRIPTION

Gets the SQL Server related services on one or more computers.



Requires Local Admin rights on destination computer(s).





PARAMETERS

-AdvancedProperties [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Credential [<Pscredential>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InstanceName [<System.String[]>]

Only returns services that belong to the specific instances.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ServiceName [<System.String[]>]

Can be used to specify service names explicitly, without looking for service types/instances.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Type [<System.String[]>]

Use -Type to collect only services of the desired SqlServiceType.

Can be one of the following: "Agent","Browser","Engine","FullText","SSAS","SSIS","SSRS", "PolyBase"



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Service, SqlServer, Instance, Connect

Author: Klaas Vandenberghe ( @PowerDBAKlaas )



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



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



Gets the SQL Server related services on computer sqlserver2014a.

-------------------------- EXAMPLE 2 --------------------------



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 --------------------------



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 --------------------------



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.

-------------------------- EXAMPLE 5 --------------------------



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 6 --------------------------



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 7 --------------------------



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 8 --------------------------



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



Calls a Restart method for each Engine service on computer sql1.



RELATED LINKS

https://dbatools.io/Get-DbaService