commands

^

Set-DbaAgentOperator

Author Tracy Boggiano (@TracyBoggiano), databasesuperhero.com
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Set-DbaAgentOperator on GitHub.
Want to see the Bill Of Health for this command? Check out Set-DbaAgentOperator.

Synopsis

Updates/modifies agent operators on an instance.

Description

Updates/modifies agent operators on an instance.

Syntax

Set-DbaAgentOperator
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Operator] <String[]>]
    [[-Name] <String>]
    [[-EmailAddress] <String>]
    [[-NetSendAddress] <String>]
    [[-PagerAddress] <String>]
    [[-PagerDay] <String>]
    [[-SaturdayStartTime] <String>]
    [[-SaturdayEndTime] <String>]
    [[-SundayStartTime] <String>]
    [[-SundayEndTime] <String>]
    [[-WeekdayStartTime] <String>]
    [[-WeekdayEndTime] <String>]
    [-IsFailsafeOperator]
    [[-FailsafeNotificationMethod] <String[]>]
    [[-InputObject] <Operator[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1

PS:>Set-DbaAgentOperator -SqlInstance sql01 -Operator DBA -EmailAddress [email protected] -PagerDay Everyday
This sets the operator named DBA with the above email address with default values to alerts everyday for all hours of the day.

Example: 2

PS:>Set-DbaAgentOperator -SqlInstance sql01 -Operator DBA -EmailAddress [email protected] -NetSendAddress dbauser1 -PagerAddress [email protected] -PagerDay Everyday -SaturdayStartTime
070000 -SaturdayEndTime 180000 -SundayStartTime 080000 -SundayEndTime 170000 -WeekdayStartTime 060000 -WeekdayEndTime 190000
Creates a new operator named DBA on the sql01 instance with email address [email protected], net send address of dbauser1, pager address of [email protected], page day as every day,
Saturday start time of 7am, Saturday end time of 6pm, Sunday start time of 8am, Sunday end time of 5pm, Weekday start time of 6am, and Weekday end time of 7pm.

Optional Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required False
Pipeline false
Default Value
-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Operator

Name of the operator in SQL Agent.

Alias
Required False
Pipeline false
Default Value
-Name

The new name of the agent operator.

Alias
Required False
Pipeline false
Default Value
-EmailAddress

The email address the SQL Agent will use to email alerts to the operator.

Alias
Required False
Pipeline false
Default Value
-NetSendAddress

The net send address the SQL Agent will use for the operator to net send alerts.

Alias
Required False
Pipeline false
Default Value
-PagerAddress

The pager email address the SQL Agent will use to send alerts to the operator.

Alias
Required False
Pipeline false
Default Value
-PagerDay

Defines what days the pager portion of the operator will be used. The default is 'Everyday'. Valid parameters
are 'EveryDay', 'Weekdays', 'Weekend', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', and
'Saturday'.

Alias
Required False
Pipeline false
Default Value
Accepted Values EveryDay,Weekdays,Weekend,Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
-SaturdayStartTime

This a string that takes the Saturday Pager Start Time.

Alias
Required False
Pipeline false
Default Value
-SaturdayEndTime

This a string that takes the Saturday Pager End Time.

Alias
Required False
Pipeline false
Default Value
-SundayStartTime

This a string that takes the Sunday Pager Start Time.

Alias
Required False
Pipeline false
Default Value
-SundayEndTime

This a string that takes the Sunday Pager End Time.

Alias
Required False
Pipeline false
Default Value
-WeekdayStartTime

This a string that takes the Weekdays Pager Start Time.

Alias
Required False
Pipeline false
Default Value
-WeekdayEndTime

This a string that takes the Weekdays Pager End Time.

Alias
Required False
Pipeline false
Default Value
-IsFailsafeOperator

If this switch is enabled, this operator will be your failsafe operator and replace the one that existed before.

Alias
Required False
Pipeline false
Default Value False
-FailsafeNotificationMethod

Defines the notification method(s) for the failsafe operator. The default is 'NotifyEmail'.
Valid parameter values are 'None', 'NotifyEmail', 'Pager', 'NetSend', 'NotifyAll'.
Values 'NotifyEmail', 'Pager', 'NetSend' can be specified in any combination.
Values 'None' and 'NotifyAll' cannot be specified in conjunction with any other value.

Alias
Required False
Pipeline false
Default Value NotifyEmail
Accepted Values None,NotifyEmail,Pager,NetSend,NotifyAll
-InputObject

SMO Server Objects (pipeline input from Connect-DbaInstance)

Alias
Required False
Pipeline true (ByValue)
Default Value
-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.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value