#Author: Jailman #Generate log cmd /c "path\to\Megacli.exe -PDlist -aALL">raid.log #Raid alert Function Alert(){ Get-Content raid.log | ForEach-Object{ if($_ -match "Predictive Failure Count") { if($_.split(":")[1].replace(" ","") -eq '0') { "Status Ok!">$null } else {"Predictive failure detected!"} } if($_ -imatch "bad") {"Bad drive detected!"} if($_ -imatch "Failed") {"Failed drive detected!"} if($_ -imatch "YES") {"SMART Alert detected!"} } } Function Mailer ($emailTo) { $message = Alert $emailFrom = "***@sina.com" $subject=$ENV:COMPUTERNAME + ": Raid alert!" $smtpserver="smtp.sina.com" #$smtp=new-object Net.Mail.SmtpClient($smtpServer) #$smtp.Send($emailFrom, $emailTo, $subject, $message) $smtpUser = "***" $smtpPassword = "***" $smtp = New-Object System.Net.Mail.SmtpClient -argumentList $smtpServer $smtp.Credentials = New-Object System.Net.NetworkCredential -argumentList $smtpUser,$smtpPassword $smtp.Send($emailFrom, $emailTo, $subject, $message) } #Send Email #$who = Read-Host "Your Email address: " $who = "***@***.com" Mailer $who
本文链接: https://www.pstips.net/powershell%e6%a3%80%e6%b5%8braid%e6%97%a5%e5%bf%97%e4%b8%8e%e9%82%ae%e4%bb%b6%e6%8a%a5%e8%ad%a6.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!