Below is the script to send status of Services and process from single server
$smtpServer = "mailserver.domain.com" #change your smtp addresss here..
$smtpFrom = "StatusReports@domain.com" #Change your from address
$smtpTo = "users@domain.com" #add users valid email address
$messageSubject = "Services and Process Status report"
$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true
$style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 5px; }"
$style = $style + "</style>"
$message.Body = Get-service |where-object{$_.Displayname -like "*SharePoint*"} | Select-Object Displayname,Name,Status | ConvertTo-Html -Head $style
$message.Body+ = Get-Process |where-object{$_.ProcessName -like"w3wp*"} | Select-Object ProcessName,Id | ConvertTo-Html -Head $style
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
$smtpServer = "mailserver.domain.com" #change your smtp addresss here..
$smtpFrom = "StatusReports@domain.com" #Change your from address
$smtpTo = "users@domain.com" #add users valid email address
$messageSubject = "Services and Process Status report"
$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto
$message.Subject = $messageSubject
$message.IsBodyHTML = $true
$style = "<style>BODY{font-family: Arial; font-size: 10pt;}"
$style = $style + "TABLE{border: 1px solid black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; background: #dddddd; padding: 5px; }"
$style = $style + "TD{border: 1px solid black; padding: 5px; }"
$style = $style + "</style>"
$message.Body = Get-service |where-object{$_.Displayname -like "*SharePoint*"} | Select-Object Displayname,Name,Status | ConvertTo-Html -Head $style
$message.Body+ = Get-Process |where-object{$_.ProcessName -like"w3wp*"} | Select-Object ProcessName,Id | ConvertTo-Html -Head $style
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
No comments:
Post a Comment