Recoverpoint Automated Email Report using Powershell

Currently for a few high priority applications, I am using Recoverpoint for VMs to replicate VMs for disaster recovery purposes. For monitoring purposes, I put together a simple script that emails a report using a combination of Windows Scheduler, Powershell and Plink.

Here is a sample of the Email report:

Sample Email Report

Here is the code I used:

#SetUp Email Variables and HTML table style
$smtp = ""
$to = ""
$from = "Recoverpoint <>"
$subject = "Recoverpoint Replication Status"
$header = @"
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #3c64af;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}

#create report array and foreach loop. This requires a text file with the different consistency group names(case sensitive) in it.
$report = @()
ForEach ($cg in (get-content D:\temp\consistencyGroups.txt)){
     $cgState = D:\temp\plink -pw password get_group_state group=$cg
     $cgStats = D:\temp\plink -pw password get_group_statistics group=$cg
     $cgState |out-file D:\temp\temp1.txt
     $cgStats |out-file D:\temp\temp2.txt
     $tempCgState = (get-content D:\temp\temp1.txt)
     $tempCgStats = (get-content D:\temp\temp2.txt)
     $statFix = $tempCgStats |select-string "WAN Traffic"
     $row = "" | Select Replication, SyncStatus, WAN_Speed
          $row.Replication = $cg
          $row.SyncStatus = $tempCgState |select-string "Data Transfer"
          $row.WAN_Speed = $statFix[-1]
          $report += $row

#create Email body using the report and the html style defined above
$body = $report| ConvertTo-HTML -Head $header |out-string

#send the email
Send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml

That’s it! This was tested using Powershell 2.0 and Recoverpoint for VMs. This should also work for the full version of Recoverpoint as well.




Leave a Reply

Your email address will not be published. Required fields are marked *