Aşağıdaki script mssqlagent durduğunda mail gönderilmek üzere ayarlanmış bir scripttir. Function EMAIL{ <# .Example: EMAIL -emailTo [email protected] -emailSubject "Test" -emailBody @"
Email Still works..
"@ #> Param( $emailSmtpServer = "smtp.office365.com", #change to your SMTP server $emailSmtpServerPort = 587, $emailSmtpUser = "[email protected]", #Email account you want to send from $emailSmtpPass = "Dot68876", #Password for Send from email account $emailFrom = "[email protected]" #Email account you want to send from ) Process{ $emailSubject ="10.100.0.18_SQL01 SQLSERVERAGENT ALERT" $emailTo = "[email protected]" $emailMessage = New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo ) $emailMessage.Subject = $emailSubject $emailMessage.IsBodyHtml = $true $emailBody = "SQLAGENT DURDU!!! Eğer bu servis durmuşsa SQL replikasyon gibi joblar çalışmaz." $emailMessage.Body = $emailBody $SMTPClient = New-Object System.Net.Mail.SmtpClient( $emailSmtpServer , $emailSmtpServerPort ) $SMTPClient.EnableSsl = $true $SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $emailSmtpUser , $emailSmtpPass ); $SMTPClient.Send( $emailMessage ) } } EMAIL