Get-​Sql​Agent

Gets a SQL Agent object that is present in the target instance of SQL Server.

Syntax

Get-SqlAgent
   [[-Path] <String>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
Get-SqlAgent
   [[-InputObject] <Server>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
Get-SqlAgent
   [[-ServerInstance] <String[]>]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-Credential <PSCredential>]
   [-ConnectionTimeout <Int32>]
   [<CommonParameters>]

Description

The Get-SqlAgent cmdlet gets a SQL Agent object that is present in the target instance of the SQL Server.

This cmdlet supports the following modes of operation:

- Specify the ServerInstance object of the target instance of SQL Server.

  • Specify the Path parameter of an instance of SQL Server.
  • Invoke the cmdlet in a valid context.

Examples

Example 1: Get the SQL Agent of a server instance

PS C:\> Get-SqlAgent -ServerInstance "MyServerInstance"
'MyServerInstance'AgentDomainGroup          : NT SERVICE\SQLSERVERAGENT
AgentLogLevel             : Errors, Warnings
AgentMailType             : SqlAgentMail
AgentShutdownWaitTime     : 15

This command gets the SQL Agent of the server instance named. MyServerInstance.

Optional Parameters

-ConnectionTimeout

Specifies the number of seconds to wait for a SQL Server connection before a timeout failure. The timeout value must be an integer value between 0 and 65534. If 0 is specified, connection attempts do not time out.

Type:Int32
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Credential

Specifies a PSCredential object used to specify the credentials for a SQL Server login that has permission to perform this operation.

Type:PSCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.The acceptable values for this parameter are:- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InputObject

Specifies the server object of the target instance.

Type:Server
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-Path

Specifies the path to the instance of SQL Server on which this cmdlet runs the operation. If you do not specify a value for this parameter, the cmdlet uses the current working location.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ServerInstance

Specifies the name of an instance of SQL Server, as an array, that becomes the target of the operation.

Type:String[]
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False