Adding a SQL Server operator
This recipe shows how you can create a SQL Server operator using SMO and PowerShell
Getting ready
For this recipe, we will create an operator with the following settings:
Setting |
Value |
---|---|
Operator name |
|
Operator e-mail |
|
If you do not have this account set up in your system, you can substitute this with another available account in your environment.
To set up an operator, you must be a sysadmin in your instance.
How to do it...
Open the PowerShell console by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Import the
SQLPS
module and create a new SMO Server object, as follows:#import SQL Server module Import-Module SQLPS -DisableNameChecking #replace this with your instance name $instanceName = "KERRIGAN" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName
Add the following script and run:
$jobserver = $server.JobServer $operatorName = "jraynor...