commands

^

New-DbaAgentOperator

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

 

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

Synopsis

Creates a new operator on an instance.

Description

If the operator already exists on the destination, it will not be created unless -Force is used.

Syntax

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

 

Examples

 

Example: 1

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

Example: 2

PS:>New-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.

Required Parameters

-Operator

Name of the operator in SQL Agent.

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.

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

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 for the failsafe oeprator. Value must be NotifyMail or NotifyPager.
The default is NotifyEmail.

Alias
Required False
Pipeline false
Default Value NotifyEmail
-Force

If this switch is enabled, the Operator will be dropped and recreated on instance.

Alias
Required False
Pipeline false
Default Value False
-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