Get-SqlAgent

SYNOPSIS

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

SYNTAX

ByPath (Default)

Get-SqlAgent [[-Path] <String>] [-InformationAction <ActionPreference>] [-InformationVariable <String>]
 [<CommonParameters>]

ByObject

Get-SqlAgent [[-InputObject] <Server>] [-InformationAction <ActionPreference>] [-InformationVariable <String>]
 [<CommonParameters>]

ByName

Get-SqlAgent [[-ServerInstance] <String[]>] [-Credential <PSCredential>] [-ConnectionTimeout <Int32>]
 [-InformationAction <ActionPreference>] [-InformationVariable <String>] [<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.

PARAMETERS

-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
Parameter Sets: ByPath
Aliases: 

Required: False
Position: 1
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
Parameter Sets: (All)
Aliases: infa

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-InformationVariable

Specifies an information variable.

Type: String
Parameter Sets: (All)
Aliases: iv

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-InputObject

Specifies the server object of the target instance.

Type: Server
Parameter Sets: ByObject
Aliases: 

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
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[]
Parameter Sets: ByName
Aliases: 

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
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
Parameter Sets: ByName
Aliases: 

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-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
Parameter Sets: ByName
Aliases: 

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS

NOTES

Get-SqlAgentJob

Get-SqlAgentJobHistory

Get-SqlAgentJobSchedule

Get-SqlAgentJobStep