Requirement
- To monitor the SharePoint service.
- Send a mail as HTML to monitoring team and SharePoint admins.
Solution
- Copy the CSS code and save as STYLE.CSS in C drive
- Copy the PowerShell script and do changes as required (Server Name, Email Address and SMTP Servers)
- Execute the script as FARM administrator
PowerShell Code
################################################################### # Script : To Monitor SharePoint Services in Farm # Developer : Chendrayan Venkatesan # Contact : Chendrayan.Exchange@hotmail.com ################################################################### $servers = "A" , "B" , "C" , "D" $Monitor = "SPAdminV4" , "SPTimerV4" , "SPTraceV4" , "SPUserCodeV4" , "SPWriterV4" , "OSearch14" , "W3SVC" , "IISADMIN" foreach($s in $servers) { $services += Get-Service -ComputerName $s -Name $Monitor | select -Property DisplayName , Status , MachineName | ConvertTo-Html -Fragment } ConvertTo-Html -Body "$services" -CssUri "C:\style.CSS" -Title "SharePoint Services" | Out-File D:\SharePoint2010_Farm_Document\SharePoint_Services.html #Send Mail $From = "Mail Address" $To = "Valid Mail Address" $smtp = "Your SMTP Server Name" $Reports = Get-Content D:\SharePoint2010_Farm_Document\SharePoint_Services.html Send-MailMessage -To $To -From $From -Attachments D:\SharePoint2010_Farm_Document\SharePoint_Services.html -Subject "Farm Services" -SmtpServer $smtp
Reference Link
http://gallery.technet.microsoft.com/scriptcenter/SharePoint-using-PowerShell-6bfcb5da