Last active
April 7, 2021 15:09
-
-
Save rbocchinfuso/06ad8a9aef58598f3660 to your computer and use it in GitHub Desktop.
NetWorker Daily Backup Report
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
NetWorker Daily Status Report | |
nw_daily_rpt.ps1 | |
Rich Bocchinfuso 2014-10-23 | |
rbocchinfuso@gmail.com | |
#> | |
### vars | |
$ver="0.1" | |
$date = Get-Date -Format D | |
## customer info | |
$cust="FOO" | |
$site="Chicago" | |
$nwsvr="CHNetworker1" | |
## nmc crdentials | |
$user="administrator" | |
$pwd="foobar11" | |
## where to store report files | |
$reportstore="\\10.10.216.9\chdd4200_bkup_infra\NW_Bkup_Reports\" | |
## mail settings | |
$smtprelay="mailhost.foo.com" | |
$smtpport="25" | |
$domain="foo.com" | |
$from="${nwsvr}@${domain}" | |
#$to="<rbocchinfuso@gmail.com>" | |
$to="<rec1@foo.com>","<rec2@bar.com>" | |
$cc="" | |
# smtp credentials (if auth is required) | |
$smtpuser = "${nwsvr}@${domain}" | |
$smtppwd = "password" | |
## report gen vars | |
# note: JAVA_HOME must be set in gstclreport.bat script | |
$gstclrpt="D:\EMC NetWorker\Management\GST\bin\gstclreport.bat" | |
$rptformat="csv" | |
$now = get-date -uformat "%Y-%m-%d_%H-%M-%S" | |
$rpt="/Reports/NetWorker Backup Status/Group Summary by Client and Server" | |
$rpttmp="rpttmp" | |
$htmlout="${reportstore}${nwsvr}_Daily_Status_${now}.html" | |
"Begin Report Script" | |
try | |
{ | |
# generate csv report | |
#write-host "$gstclrpt -u $user -P $pwd -r `"$rpt`" -x $rptformat -o landscape -f `"$reportstore$rpttmp`" -C `"Group Start Time`" `"1 day ago`" -C `"Server Name`" $nwsvr" | |
& $gstclrpt -u $user -P $pwd -r `"$rpt`" -x $rptformat -o landscape -f `"$reportstore$rpttmp`" -C `"Group Start Time`" `"1 day ago`" -C `"Server Name`" $nwsvr | |
### convert csv to html | |
# html report format | |
$title = "$nwsvr Daily Backup Report" | |
$style = @" | |
<style> | |
TABLE{border-width: 3px;border-style: solid;border-color: black;border-collapse: collapse;} | |
TH{border-width: 2px;text-align: center;padding: 10px;border-style: solid;border-color: black;font-family: Arial;color: #FFFFFF;background-color:#08088A} | |
TD{border-width: 2px;text-align: center;padding: 10px;border-style: solid;border-color: black;font-family: Arial;color: #0A0A2A;background-color: #FAFAFA} | |
tr.special {background: #000080;} <tr class="special"></tr> | |
</style> | |
"@ | |
$rpthead = @" | |
<font face="Arial"><b> | |
Customer: $cust<br> | |
Site: $site<br> | |
NetWorker Server: $nwsvr<br> | |
Report Date: $date<br> | |
</b></font> | |
"@ | |
#write-host "Get-Content "$reportstore$rpttmp.csv" | select -skip 10 | ConvertFrom-Csv | ConvertTo-Html -head $style | Out-File $htmlout" | |
Get-Content "$reportstore$rpttmp.csv" | select -skip 10 | ConvertFrom-Csv | ConvertTo-Html -title $title -head $style -body $rpthead | Out-File $htmlout | |
<# | |
## email report for powershell < ver 2 | |
$emailMessage = New-Object System.Net.Mail.MailMessage( $from , $to ) | |
$date = Get-Date -Format D | |
$emailMessage.Subject = " $nwsvr Daily Backup Report - " + $date | |
$emailMessage.IsBodyHtml = $true | |
$emailMessage.Body= (Get-Content $htmlout ) | |
$body = (Get-Content $htmlout ) | |
$SMTPClient = New-Object System.Net.Mail.SmtpClient( $smtprelay , $smtpport ) | |
$SMTPClient.EnableSsl = $false | |
## uncomment the following line if smtp auth is required | |
#$SMTPClient.Credentials = New-Object System.Net.NetworkCredential( $smtpuser , $smtppwd ); | |
$SMTPClient.Send( $emailMessage ) | |
#> | |
## email report for powershell >= ver 2 | |
$subject = " $customer - $site - $nwsvr Daily Backup Report - " + $date | |
$body = (Get-Content $htmlout | out-string) | |
send-mailmessage -from $from -to $to -subject $subject -body $body -bodyashtml -smtpserver $smtprelay | |
} | |
catch [system.exception] | |
{ | |
"caught a system exception" | |
} | |
finally | |
{ | |
"Report Script Complete" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could some one pls help to fix the below issue.
PS D:\Program Files\EMC NetWorker\Management\GST\bin> .\gstclreport.bat
Your current JAVA_HOME is
Java Runtime Environment Version 7 is required to run this script.
Please read comments at the top of gstclreport.bat file to set
JAVA_HOME to a valid JRE location.