Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Requires the Netapp Powershell toolkit installed
  2.  
  3. # Export credential to file. Restricted to user that created the file. If running this on a schedule make sure the .xml is generated with the account that will run the task  
  4.  
  5. # Generate the credential file(Better than plain txt passwords in scripts) GET-CREDENTIAL –Credential “user-account” | EXPORT-CLIXML C:\SecureLocation\NetappSecureCredentials.xml
  6.  
  7.  
  8.  
  9. $ReportOutput ="<h1><center>NetApp Cluster Replication Report</center></h1>"
  10.  
  11. Import-Module DataONTAP
  12.  
  13. $targetdate = (get-date)
  14.  
  15. $credential= Import-Clixml C:\SecureLocation\NetappSecureCredentials.xml
  16.  
  17. Connect-NcController -Name BackupFilerName -Credential $credential
  18.  
  19.  
  20.  
  21. $ReportOutput += "<h2>Report run on: $targetdate</h2>"
  22.  
  23.  
  24.  
  25. $ReportOutput += "<hr size=.5 width=100% align=left color='green'>"
  26.  
  27. $ReportOutput += "<h2>SnapVault Relationship Health</h2>"
  28.  
  29.  
  30.  
  31. $Results = get-ncsnapmirror | select-Object @{Name="RPO Meet";Expression={$_.Lagtime -lt 14400}}, SourceVolume, DestinationVolume, @{Name="Transfer Size MB"; Expression={"{0:N2}" -f ($_.LastTransferSize /1Mb)}} ,NewestSnapshotTimestampDT, NewestSnapshot,@{Name="Lag";Expression={[timespan]::fromseconds($_.LagTime).tostring()}}, IsHealthy
  32.  
  33. $ReportOutput += $Results | sort lag -Descending | ConvertTo-HTML -Fragment
  34.  
  35.  
  36.  
  37. $head= "<style>
  38.  
  39. body {font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;}
  40.  
  41. table {border-collapse:collapse; border:#b1babf 1px solid; font:10pt Verdana, Geneva, Arial, Helvetica, sans-serif;color: black;}
  42.  
  43. th {font-size: 12px; font-weight: bold; padding:5px 10px; text-align: left;border:#b1babf 1px solid;background-color:#A7C942;color:#fff;}
  44.  
  45. td{font-size: 12px; padding:5px 5px; text-align: left;border:#b1babf 1px solid;}
  46.  
  47. h1{ clear: both; font-size: 24pt; margin-left: 20px; margin-top: 30px;}
  48.  
  49. h2{ clear: both;font-size: 115%; margin-left: 20px; margin-top: 30px;}
  50.  
  51. h3{ clear: both;color:red; font-size: 115%; margin-left: 20px; margin-top: 30px;}
  52.  
  53. h4{clear: both; color:green; font-size: 10pt;margin-left: 20px; margin-top: 30px;}
  54.  
  55. h5{ clear: both; font-size: 16pt; margin-left: 20px; margin-top: 30px;}
  56.  
  57. h6{BORDER-BOTTOM: #b1babf 1px solid; POSITION: relative; BORDER-LEFT: #b1babf 1px solid; BACKGROUND-COLOR: #0061bd; PADDING-LEFT: 5px; DISPLAY: block; FONT-FAMILY: Tahoma; HEIGHT: 2em; COLOR: #ffffff; MARGIN-LEFT: 0px; FONT-SIZE: 12pt; BORDER-TOP: #b1babf 1px solid; FONT-WEIGHT: bold; MARGIN-RIGHT: 0px; BORDER-RIGHT: #b1babf 1px solid; PADDING-TOP: 8px}
  58.  
  59. table tr:nth-child(even) { background-color: #DBE5F1; }
  60.  
  61. table tr:nth-child(odd) { background-color: #EAF1DD; }
  62.  
  63. </style>"
  64.  
  65.  
  66. if($ReportOutput -ne $null)
  67.  
  68. {
  69.  
  70. $emailFrom = "SnapVaultReport@companyname"
  71.  
  72. $emailTo = "BackupAlerts@companyname"
  73.  
  74. $subject = "SnapVault Report"
  75.  
  76. $body = "" | ConvertTo-HTML -head:$head -body:$ReportOutput | foreach {$PSItem -replace "<td>False</td>", "<td style='background-color:#FF8080'>False</td>"} | Out-string
  77.  
  78. $smtpServer = "mail.server.com"
  79.  
  80. Send-MailMessage -SmtpServer:$smtpServer -To:$emailTo -From:$emailFrom -Subject:$subject -Body:$body -BodyAsHtml
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement