You could try something like this:
Connect-NaController yourcontroller
$sms = Get-NaSnapmirror
$smerror = $null
$newline = "`n"
foreach ($sm in $sms){
if ($sm.state -ne "snapmirrored"){
Write-Host "Errors found. `tSource: $($sm.source)`t`t Destination: $($sm.Destination) `t`tState: $($sm.State)"
$smerror += @($sm.Source,$sm.Destination,$sm.State,$newline)
}
}
Send-MailMessage -To "you@yourdomain.com" -From "powershell@yourdomain.com" -Subject "Snapmirror errors found!" -Body "$smerror" -BodyAsHtml -SmtpServer yoursmtpserver
I'm making some assumptions here though.
1. I'm assuming you're using powershell v3 and DataOntap toolkit v3.0.
2. I'm assuming you have cached credentials to your filers via add-nacredential.
3. You're able to make send-mailmessage look pretty
Also, I wouldn't modify this script to run in a loop forever - That's generally a no-no with powershell. Use task scheduler (or whatever other tasking tool) to launch it at set intervals.