PowerShell script exchange
Post Reply
Charly.Fr
Novice
Posts: 3
Liked: 5 times
Joined: Jun 16, 2023 2:19 pm
Full Name: Charly FR
Contact:

Powershell reports

Post by Charly.Fr » 5 people like this post

Hi everyone,

I wrote some reports that helps me to improve my backup configuration. I just put them online if you want to use them.

Here is a morning report that shows the result of the backup jobs during the night (Veeam One reports are unusable) :
https://github.com/VeeamHub/powershell/ ... ningReport

Image

And this one shows the duration and the layout between backup jobs to improve schedules :
https://github.com/VeeamHub/powershell/ ... tionReport

Image

Feel free to use them and custom them (after some use, i cut off the description and instructions in the template email to have the resume at the top of the mail). If you too have wrote something useful, please share it on VeeamHub :wink:
Mildur
Product Manager
Posts: 9595
Liked: 2543 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Powershell reports

Post by Mildur » 1 person likes this post

Hello Charly

Thank you for the report :) If you want, you may also share it on our Community board in the script library:
https://community.veeam.com/script-library-67

Could you maybe share with me, why the Veeam One Reports are unusable?
Both Reports can be created (similar) with Veeam One too. I'm happy to forward your feedback to our Veeam One team.

Best,
Fabian
Product Management Analyst @ Veeam Software
Charly.Fr
Novice
Posts: 3
Liked: 5 times
Joined: Jun 16, 2023 2:19 pm
Full Name: Charly FR
Contact:

Re: Powershell reports

Post by Charly.Fr »

I'll do that :+1:

My company had Veeam One but no one simply resume the number of success and failed jobs in the past night. Sometimes i do some tests during the day and some fails, those scripts can exclude them by choosing the period of time. The Veeam One report cannot be scheduled so easily.

I've scheduled the morning report at 9:00 and survey the past 15 hours, that means from 18:00 the day before.
jorgedlcruz
Veeam Software
Posts: 1465
Liked: 641 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Powershell reports

Post by jorgedlcruz »

Hello Charly,
Very great look and feel. Awesome job, as Fabian mentioned, the guys at the Community will love it too.

I am currently working on Veeam ONE, and I always love to get feedback and include ideas, and share as well of course.

Currently we have a few reports like this:
https://helpcenter.veeam.com/docs/one/r ... story.html
https://helpcenter.veeam.com/docs/one/r ... tatus.html
And perhaps even playing with this https://helpcenter.veeam.com/docs/one/r ... _data.html

I agree that times period sometimes are a bit less flexible, we are working on that.

For Jobs calendar, or to show the job duration on the calendar, VONE v12 has a view for that:
https://helpcenter.veeam.com/docs/one/r ... endar.html

Now, if you still have all the info in VONE and it is the time duration what is not flexible enough. I would recommend you to look at the stored procedures, and with a powershell take the data out of the report with your custom interval, and render it on HTML same as you did.

As said, great work, keep awesome ideas coming.

Thanks a lot.
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
Charly.Fr
Novice
Posts: 3
Liked: 5 times
Joined: Jun 16, 2023 2:19 pm
Full Name: Charly FR
Contact:

Re: Powershell reports

Post by Charly.Fr »

Hello Jorge,

I'm please to talk with someone from Veeam One. You certainly recognize the mail i designed, i tried to copy the Veeam One report style.

One of the disadvantages in Veeam One, as i said, is the period of time that cannot be adjusted finely, but It’s not the only one. I wrote my own reports because those you mentioned are useless in everyday life.

Latest Job Status
This report is the most likely to be used by everyone but there's no sorting by status, it takes several pages instead of using only one, there's a lack of color for the results and we can't choose the column to show. And the pie chart is useless.

Image

Job History
This one is beautiful but we don't care the amount of data transferred. My colleagues only want to know if there's something to debug or not. They want to see a green light. Backups are just a line in our morning checklist.

Image

Backup Infrastructure Custom Data
This one is okay... but it doesn't shows the backups status, so it's useless.

Image

Jobs Calendar
This one is nice. I never used it, i admit. But it can be useful if you can choose the period of time (and it's possible as i see)

Image

Sorry if i'm direct, i was just pissed when we bought Veeam One to see that no report can do what we wanted, that is : listing the backup jobs status from last night sorted by 'Failed' to 'Success' with colors as a bonus. When i saw Veeam One reports the first time, i was disappointed that they were not designed by the users but only by Veeam staff that tried to imagined the clients' needs, instead of asking them what they really want.

If i can helps you to improve your software, the first two scripts are free of charge :lol:
desmith
Influencer
Posts: 24
Liked: 2 times
Joined: Dec 15, 2021 11:41 pm
Full Name: Derek Smith
Contact:

Re: Powershell reports

Post by desmith » 1 person likes this post

Thanks for sharing, looks very useful.

I have a very low opinion of Veeam One, full bugs that make its reports critically unreliable, and out of box reports never gave us an overview of data protection state.

I wrote some terrible powershell to make a summary report out of its XML output (which is the worst data structure I've seen in a long time) but you've clearly gone next level.
alesovodvojce
Enthusiast
Posts: 62
Liked: 9 times
Joined: Nov 29, 2016 10:09 pm
Contact:

Re: Powershell reports

Post by alesovodvojce »

these reports looks fantastic. Going to implement them right now. Thanks, Charly!
jorgedlcruz
Veeam Software
Posts: 1465
Liked: 641 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Powershell reports

Post by jorgedlcruz »

Thank you for the feedback Charly, we are working hard to resolve all reporting issues, that is making it more flexible, and fresh, but it will take time.

Despite, that is an interesting feedback, what will you like to see on a report or dashboard that will give you an entire overview data protection visibility? Is that jobs? Workloads?

Thank you so much. If you think we are discussing too much here, we can move to Veeam ONE forum, last thing I want is to derail the great work from Charly.

Thanks a lot!
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
asgard79
Influencer
Posts: 12
Liked: never
Joined: Jul 07, 2021 8:46 am
Contact:

Re: Powershell reports

Post by asgard79 »

Charly.fr, great job !
We don't have Veeam One. Your report will help backup operator certainly.
Did you look at how to historize job status, total jobs size ?
dome73
Lurker
Posts: 2
Liked: never
Joined: Mar 09, 2011 10:08 am
Full Name: Domenico
Contact:

Re: Powershell reports

Post by dome73 »

Charly.fr, I found very useful your "Duration Report".

I made some changes on your script to enable different starting hour and to extend view to a 24 hours period.

First I truncated mail template after line 74 (named $mail_header_path), then I changed some lines in the "region CODE" to handle new parameter $StartAt, before sending email.
This is modified code:

Code: Select all

try {
    log -level HIGH -entry "Script started"
    Add-PSSnapin VeeamPSSnapin -ea SilentlyContinue
    # Get jobs infos
	If (($StartAt -ge 24) -or ($StartAt -lt 0) -or ( ($StartAt % 1) -ne 0 )) { echo "ERROR: Hour not valid!"; exit 1 }
	If ($StartAt -le 9) { $Start_Hour = "0${StartAt}:00"  } else { $Start_Hour = "${StartAt}:00" }
	$period_start = [System.DateTime]::Parse($Start_Hour).AddDays(-1) # yesterday
	$period_end   = [System.DateTime]::Parse($Start_Hour) # today
    $sessions = @(get-LastSessions -between $period_start -and $period_end)
    log -level INFO -entry "$($sessions.count) sessions found"
    # Here begin the mail construction, $mail_Body
	$mail_Body = Get-Content $mail_header_path
	for ( ($i = $StartAt); $i -le ($StartAt + 24); ($i = $i + 3) ) {
		if ( $i -le 9 ) { 
			$j = "0$i" 
		} else { 
			if ( $i -gt 24 ) { $j = $i - 24;  if ( $j -le 9 ) { $j = "0$j" } } else { $j = $i } 
		}
		$mail_Body += "<th class=""bold-border"">$j</th><th>h</th><th></th><th></th><th></th><th></th>"
	}
    $mail_Body += "</tr></thead><tbody id=""table-details"">"
    foreach($session in $sessions) {
        $mail_Body += "<tr>"
	    $mail_Body += "  <td class='first-row'>$($session.Name)</td>"
        # Colors are always nice
        switch($session.result) {
            'Success' { $result = 'blue';   break }
            'Warning' { $result = 'yellow'; break }
            'Failed'  { $result = 'red';    break }
            default   { $result = 'blue';   break }
        }
        $cursor = $period_start
        while($cursor -le $period_end) {
			$curstr = $cursor.ToString("HHmm")
			$curnum = [int]$curstr
			$curnum = $curnum / 100
			if ($curnum -ge $StartAt) { $curnum = $curnum - $StartAt } else { $curnum = $curnum + 24 - $StartAt}
            if ( ($curnum % 3) -eq 0 ) {
	            $fatBorder = 'border-left: 2px solid #777;'
            } else {
	            $fatBorder = ''
            }
            $cursor = $cursor.AddMinutes(30)
            if($session.StartTime -lt $cursor -and ($session.EndTime.AddMinutes(30) -gt $cursor -or $session.EndTime -eq [datetime]::Parse('01/01/1900'))) {
	            $barColor = $result
            } else {
	            $barColor = 'white'
            }
            $mail_Body += "  <td class='bg-$barColor' style='width: 20px; $fatBorder'></td>"
        }
	    $mail_Body += "</tr>"
    }
    # finnishing mail construction with the end of template
    $mail_Body += "</tbody></table></div></body></html>"
    # last touch
    $Today = $(Get-Date -Format 'dd/MM/yyyy')
    $mail_string = $mail_Body -join "`n"
    $mail_string = $mail_string.replace('$Title', "Duration report")
    $mail_string = $mail_string.replace('$Today', "$Today - $StartAt h")
    $mail_string = $mail_string.replace('$width', (($sessions | select Name).Name | sort length | select -Last 1).length*10)
    $mail_string | Out-File $GLOBAL:Report
I wish this could be useful.

Thank you
Mildur
Product Manager
Posts: 9595
Liked: 2543 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Powershell reports

Post by Mildur »

Hi Domenico

Thank you. I have updated your post with code tags to make it better readable.

Best,
Fabian
Product Management Analyst @ Veeam Software
ghaxians
Service Provider
Posts: 6
Liked: 3 times
Joined: Aug 31, 2016 2:51 pm
Full Name: Gilles
Contact:

Re: Powershell reports

Post by ghaxians » 1 person likes this post

jorgedlcruz wrote: Jul 06, 2023 12:51 pm Hello Charly,
Very great look and feel. Awesome job, as Fabian mentioned, the guys at the Community will love it too.

I am currently working on Veeam ONE, and I always love to get feedback and include ideas, and share as well of course.

Currently we have a few reports like this:
https://helpcenter.veeam.com/docs/one/r ... story.html
https://helpcenter.veeam.com/docs/one/r ... tatus.html
And perhaps even playing with this https://helpcenter.veeam.com/docs/one/r ... _data.html

I agree that times period sometimes are a bit less flexible, we are working on that.

For Jobs calendar, or to show the job duration on the calendar, VONE v12 has a view for that:
https://helpcenter.veeam.com/docs/one/r ... endar.html

Now, if you still have all the info in VONE and it is the time duration what is not flexible enough. I would recommend you to look at the stored procedures, and with a powershell take the data out of the report with your custom interval, and render it on HTML same as you did.

As said, great work, keep awesome ideas coming.

Thanks a lot.
Hi Jorge,

Jumping in on this very interesting thread, to provide my feedback.
I am an IT project manager for an IT Service Company, and what my clients want to know every morning is if everything ran ok or if they need to take action :
  • did all my job run ?
  • what VM/server failed or had an error during backup ? (if there is an issue, what are the associated job and error message ?
We did not find that information readily available in Veeam One or in the Veeam console.
In veeam console, if a job fails for some VMs, one has to check which ones failed or had warnings in the job logs, then look at the job retries to see if these specific VMs where correctly backed-up afterwards or not.
(sorry if my choice of words is not the greatest).

All the other information might be nice to have, especially when troubleshooting, but all they want to know first in the morning it if there are issues to deal with or not, on which VM or server. One job can group so many VMs, it's mandatory to specify which VM/server needs some work done.

We had to write scripts to provide just that information.

Afterwards, they might be interested to see a report on performances, repository volume usage stats etc. in order to be able to forecast changes to the infrastructure, but maybe not every morning, but first focus is on data protection.

Best regards,
dries.vergote
Service Provider
Posts: 40
Liked: 5 times
Joined: Apr 24, 2015 2:51 pm
Full Name: Dries Vergote
Contact:

Re: Powershell reports

Post by dries.vergote »

Hi Charly

Great script.
I have adjusted some of your specific code for you.
f.e. where statement in backup agent to exclude -cl* in de name.
And also your splits on the job & server names.

I have tested it both to V11 and V12.
In V12 it doesn't shows the encrypted jobs anymore.
Still checking that out.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest