Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Change SQL Agent Job notification operator

$
0
0

Need help with this powershell script that will assign operator email for failure.  Here is what I have:

$server = "SQLSERVER\NAMED_INSTANCE"
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null;
$srv = new-object Microsoft.SqlServer.Management.Smo.Server ($server)
foreach ($job in $srv.JobServer.jobs)
{
$job.EmailLevel = [Microsoft.SqlServer.Management.Smo.Agent.CompletionAction]::OnFailure
$job.OperatorToEmail = "SQLADMINS"
}
When I run it, it says script execution completed but after I checked nothing changed.  Any idea?



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>