Um einen einfachen Hyper-V Replica zu überwachen, habe ich folgenden Script über den Aufgabenplaner am laufen. Der überprüft (bei mir) einmal im Tag ob der der Status auf Warning oder Critical ist und sendet ein E-Mail an den Admin.
$SMTPServer = "smtp.mailserver.com" $SMTPPort = "587" $Username = "username@domain.ch" $Password = "password" $to = "admin@domain.ch" $from = "HyperV SERVER <no-reply@domain.ch>" if ((Get-VMReplication | select-string -inputobject {$_.Health} -pattern "Warning") -like "Warning") { $subject = "Replica WARNING error on Hyper-V" $message = New-Object System.Net.Mail.MailMessage $message.subject = $subject $message.to.add($to) $message.from = $from $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort); $smtp.EnableSSL = $false $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password); $smtp.send($message) } elseif ((Get-VMReplication | select-string -inputobject {$_.Health} -pattern "Critical") -like "Critical") { $subject = "Replica CRITICAL error on Hyper-V" $message = New-Object System.Net.Mail.MailMessage $message.subject = $subject $message.to.add($to) $message.from = $from $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort); $smtp.EnableSSL = $false $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password); $smtp.send($message) }
Hyper-V Replica Monitoring