简体   繁体   中英

Powershell script to change operator email address notification

This is the script I have been trying to get work:

 [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null

$server = "servername"

$srv = new-object ("Microsoft.SqlServer.Management.Smo.Server") $server

$op = new-object ("Microsoft.SqlServer.Management.Smo.Agent.Operator") $srv.JobServer, "DBA Team"

$op.emailAddress = "johndoe@gmail.com" 
$op.alter

To change the email address for an existing operator use this.

$srv.JobServer.Operators.Item('DBA Team').EmailAddress = 'johndoe@gmail.com'
$srv.JobServer.Operators.Item('DBA Team').Alter()

Your code is almost what you would use to add a new operator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM