Maintain control of your Microsoft 365 data
Post Reply
avaleksandrov
Influencer
Posts: 12
Liked: 1 time
Joined: Oct 21, 2022 3:38 pm
Contact:

Script

Post by avaleksandrov »

Hi all!
Does anyone have a script that allows you to display information on the job.

For example, the last status of the job is of interest. Information on assignment within 72 hours.
jorgedlcruz
Veeam Software
Posts: 1495
Liked: 655 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Script

Post by jorgedlcruz »

Hello,
Well, you have not specified, so what I can share is a great visibility into Grafana using an script:
https://grafana.com/grafana/dashboards/ ... osoft-365/

If you wait until v7 of VB365, and Veeam ONE v12, more reporting will be available natively.

You can use that shell script there to take just the backup jobs part, and instead sending the output to InfluxDB, just send an email.

Or now looking through more scripts, perhaps this is what you are looking for?
https://jorgedelacruz.uk/2021/08/03/vee ... y-project/

Hope this is enough.

Thanks!
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
avaleksandrov
Influencer
Posts: 12
Liked: 1 time
Joined: Oct 21, 2022 3:38 pm
Contact:

Re: Script

Post by avaleksandrov »

I created such a script that collects information on a task and generates a report in html format.
I think it turned out well.

If someone could add that the color of the report changes when Warning or Failed, that would be cool.

Or write such an html format as VBR reports, where previous tasks are also indicated, that would be cool. :!:

Code: Select all

$ReportDate = Get-Date -format "MM-dd-yyyy"
 

$SmtpServer = "" 
$EmailFrom = ""
$EmailTo = ""
$EmailSubject = "Report $name "+$ReportDate
 
$job = Get-VBOJob -name jobname
$status = $job.LastStatus
$name = $job.Name
$job_stats_get = Get-VBOJobSession -Job $job -Last
$job_stats_get.statistics


$EmailBody = @"
<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-aff0{background-color:#00B050;color:#ffffff;border-color:inherit;font-size:36px;text-align:center;vertical-align:top}
.tg .tg-1hfs{background-color:#ffffff;border-color:inherit;font-size:22px;text-align:left;vertical-align:top}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg">
<thead>
  <tr>
    <th class="tg-aff0" colspan="9"><span style="font-weight:bold">$name</span></th>
  </tr>
</thead>
<tbody>
  <tr>
    <td class="tg-1hfs" colspan="9">Status: <span style="font-weight:bold">$status</span></td>
  </tr>
  <tr>
    <td class="tg-0pky" colspan="2">Start Time</td>
    <td class="tg-0pky">End Time</td>
    <td class="tg-0pky">ProcessingRate</td>
    <td class="tg-0pky">ReadRate</td>
    <td class="tg-0pky">WriteRate</td>
    <td class="tg-0pky">TrsnferredRate</td>
    <td class="tg-0pky">ProcessedObjects</td>
    <td class="tg-0pky">Bottleneck</td>
  </tr>
  <tr>
    <td class="tg-0pky" colspan="2">$($job_stats_get.CreationTime)</td>
    <td class="tg-0pky">$($job_stats_get.EndTime)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.ProcessingRate)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.ReadRate)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.WriteRate)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.TransferredData)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.ProcessedObjects)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.Bottleneck)</td>
  </tr>
</tbody>
</table>
"@  
 
 
$EmailBody= $EmailBody.Replace("VarApproved",$ApprovedCount)
$EmailBody= $EmailBody.Replace("VarRejected",$RejectedCount)
$EmailBody= $EmailBody.Replace("VarReportDate",$ReportDate)

Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer -Encoding UTF8


jorgedlcruz
Veeam Software
Posts: 1495
Liked: 655 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Script

Post by jorgedlcruz »

Amazing,
I will give it a try this week, and try to add color or formatting according to status.

Thanks for sharing!
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
avaleksandrov
Influencer
Posts: 12
Liked: 1 time
Joined: Oct 21, 2022 3:38 pm
Contact:

Re: Script

Post by avaleksandrov » 1 person likes this post

Modified the script a little, added a different color for success and failure.

If you have more ideas for improvement, then here is the script

Code: Select all

$ReportDate = Get-Date -format "MM-dd-yyyy"

$job = Get-VBOJob -name jobname
$status = $job.LastStatus
$name = $job.Name
$job_stats_get = Get-VBOJobSession -Job $job -Last
$job_stats_get.statistics

$SmtpServer = "" 
$EmailFrom = ""
$EmailTo = ""
$EmailSubject = "Report "  +$name+ " "   +$ReportDate
 


$bg_color = '#00B050'

if ( $status -eq "Success" )
{
    $bg_color = '#00B050'
}
else 
{
 $bg_color = '#FB9895'
}

$EmailBody = @"
<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-aff0{background-color:$bg_color;color:#ffffff;border-color:inherit;font-size:36px;text-align:center;vertical-align:top}
.tg .tg-1hfs{background-color:#ffffff;border-color:inherit;font-size:22px;text-align:left;vertical-align:top}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg">
<thead>
  <tr>
    <th class="tg-aff0" colspan="9"><span style="font-weight:bold">$name</span></th>
  </tr>
</thead>
<tbody>
  <tr>
    <td class="tg-1hfs" colspan="9">Status: <span style="font-weight:bold">$status</span></td>
  </tr>
  <tr>
    <td class="tg-0pky" colspan="2">Start Time</td>
    <td class="tg-0pky">End Time</td>
    <td class="tg-0pky">ProcessingRate</td>
    <td class="tg-0pky">ReadRate</td>
    <td class="tg-0pky">WriteRate</td>
    <td class="tg-0pky">TrsnferredRate</td>
    <td class="tg-0pky">ProcessedObjects</td>
    <td class="tg-0pky">Bottleneck</td>
  </tr>
  <tr>
    <td class="tg-0pky" colspan="2">$($job_stats_get.CreationTime)</td>
    <td class="tg-0pky">$($job_stats_get.EndTime)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.ProcessingRate)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.ReadRate)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.WriteRate)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.TransferredData)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.ProcessedObjects)</td>
    <td class="tg-0pky">$($logbox_stats_get.statistics.Bottleneck)</td>
  </tr>
</tbody>
</table>
"@  
 
 
$EmailBody= $EmailBody.Replace("VarApproved",$ApprovedCount)
$EmailBody= $EmailBody.Replace("VarRejected",$RejectedCount)
$EmailBody= $EmailBody.Replace("VarReportDate",$ReportDate)

Send-MailMessage -To $EmailTo -From $EmailFrom -Subject $EmailSubject -Body $EmailBody -BodyAsHtml -SmtpServer $SmtpServer -Encoding UTF8


Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests