PowerShell script exchange
arno
Influencer
Posts: 12
Liked: 1 time
Joined: Jun 18, 2009 9:21 am
Contact:

Generate Veeam Session Report (HTML) from Powershell

Post by arno »

Hello,

After many searches in documentation and forums, I'm still looking for a way to generate HTML report from command line (Powershell or other way).

I don't want any specific or fancy report, I just want to click on this using CLI :
Image

Could you help me on this ?

Thanks in advance.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by veremin »

Hi,

Please, take a look at the existing report created by one of our users and see whether it meets your expectations.

Thanks.
arno
Influencer
Posts: 12
Liked: 1 time
Joined: Jun 18, 2009 9:21 am
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by arno »

Hi,

Thanks a lot for your answer.

I've already seen this, it is a great report, but I don't have any use of this.

All I want is the official Veeam session report. I can't have it sent by Veeam Backup itself, as my jobs are launched and managed by an external tool.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by veremin »

It seems to contain everything you're after. Even the representation appears to be in HTML.

Anyway, the approach will be write something similar yourself. You'll have to find the last session of given job and get from it whatever parameters you want to. For instance,

Code: Select all

asnp VeeamPSSnapin
$Job = Get-VBRJob -Name "Name of your job"
$Session = $Job.FindLastSession()
$Session.State
$Session.CreationTime
$Session.EndTime
$Session.Info.BackupTotalSize
$Session.BackupStats.CompressRatio
$Session.BackupStats.DataSize
$Session.BackupStats.DedupRatio
Thanks.
arno
Influencer
Posts: 12
Liked: 1 time
Joined: Jun 18, 2009 9:21 am
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by arno »

Thanks for your help.

So, it's not possible to use Veeam builtin reports from CLI ?
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by veremin »

Yep, there is no such a thing like "generate report" method. However, with some efforts you can create similar report, using PS capabilities, since the given data is available and can be gotten via PowerShell smoothly. Thanks.
arno
Influencer
Posts: 12
Liked: 1 time
Joined: Jun 18, 2009 9:21 am
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by arno »

Well, it seems a bit reinventing the wheel... When I click on the appropriate option in GUI, I even have the HTML report generated in C:\Users\username\AppData\Local\Temp.

I guess it's time to use AutoHotKey to achieve that...
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by veremin »

Not sure whether the usage of AutoHotKey would be easier than implementing simple PS script or even taking existing PS report, but you should certainly use the approach that suites your needs and desires best. Thanks.
khanahsan
Lurker
Posts: 1
Liked: never
Joined: Sep 16, 2014 1:39 pm
Full Name: Khan Ahsan Masroor
Contact:

[MERGED] : Backup Job Details-Report extraction

Post by khanahsan »

Hello everyone,

I want to extract a report from Veeam B&R about the Backup job details,properties and schedules of all already created jobs in a report format.
how can I get it via Powershell ?
There's not too much filtering options in Veeam Enterprise Manager for reporting and Analysis.
Please guide me through .
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by veremin »

Your post has been merged into existing discussion regarding similar matter. Please, check the answers provided above. Thanks.
OllyS
Lurker
Posts: 1
Liked: never
Joined: Sep 17, 2014 10:34 am
Contact:

[MERGED] : Retrieve Data Read and Transferred figures

Post by OllyS »

Hi,

I know you can view the properties of the backup under 'Disks' and see stats like data size and backup size, but when comparing them to the job history, these aren't exactly the same.

I need a script the retrieve each the figures for 'Read' and 'Transferred' from each job every morning, is there an simple way to do this?

Thanks
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by veremin »

Hi, Olly, kindly check the answers provided above; should be helpful. Thanks.
Jack1874
Enthusiast
Posts: 95
Liked: 5 times
Joined: Oct 17, 2015 3:32 pm
Full Name: Stuart Little
Location: Canada
Contact:

[MERGED] : Export List of Transferred Data

Post by Jack1874 »

Hello, is it possible to report on \ export a list of Transferred data from each job... from the previous run?

TIA
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by veremin »

You need to modify the script provided above to get the desired information for all jobs. A simple cycle would be enough. Thanks.
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

[MERGED] Daily Report on a single job

Post by gveat »

How would I generate a report that mimics that of the gui? I want to have a report created daily that mimics what is seen in the gui if you click on report for a particular job.
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by gveat »

How do I output this to a file?
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by PTide »

You can use the Out-File PS cmdlet

Thanks
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by gveat »

I receive a can't pipe error. Where do I add that to the script? I don't know much about Powershell, other how to copy and paste others work.
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by PTide »

First of all it's difficult to troubleshoot the script without actually seeing it and the error it gives. Secondly, since this community provides a free of charge best effort support it would be very nice of you if you used forum search engine because many questions have already been answered before. For example this report created by one of our memebers might give you some hints regarding how to generate your own report using PowerShell. Also if you're looking for a decent reporting tool then Veeam ONE is worth checking.

Thank you!
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by gveat »

I just started evaluating Veeam One today.

As for the other issues. I am using the script from this thread. No alterations other than naming the job.
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by tdewin »

I'm making a pull request for https://github.com/VeeamHub/powershell , but you can already find the MimicReport I hacked together last night here https://github.com/tdewin/powershell/tr ... imicReport . Basically it tries to mimic the report. It should be fairly easy to modify if you don't want to send it to a file, but mail it instead
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by gveat » 1 person likes this post

This is perfect. Thank you. I have it setup to output to a file. After looking and searching and searching, I've noticed a couple of things. Veeam ONE needs a way to do custom B&R reports. Most of the big time scripts change not only from B&R version 7 to 8 to 9 but also from PS versions 2 to 3 to 4 to 5. Thank you again PTide and tdewin.
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by gveat »

How do I output just the last session? I see the note to do so and it doesn't make sense to me.

Code: Select all

if ($JobName -ne $null) {

    $Jobs = @(Get-VBRJob -Name $JobName)

    if ($Jobs.Count -gt 0) {

        $Job = $Jobs[0];

        $jt = $job.JobType;



        if ($jt -eq "Backup" -or $jt -eq "Replication" -or $jt -eq "BackupSync") {

            $sb = New-Object -TypeName "System.Text.StringBuilder";

            write-reportmimicheader $sb

            write-reportmimicheadertable $sb



            #if you want other sessions, for example, last session of each job, you could capture all sessions first without a filter ($allsessions = get-vbrbackupsession) , then create a for loop to go over all jobs and then use $sessions = $allsesions | ? {..} with a filter to select the sessions you like

            #you should be able to call write-reportemimicrecord multiple times on the same stringbuilder

            $sessions = Get-VBRBackupSession -Name ("{0}*" -f $Job.Name) | ? { $_.jobname -eq $Job.Name } 

            $orderdedsess = $sessions | Sort-Object -Property CreationTimeUTC -Descending





            if ($Max -gt 0 -and $Max -lt $orderdedsess.Count) {

                $orderdedsess = $orderdedsess | select -First $Max

            }



            foreach($sess in $orderdedsess) {

                write-reportmimicrecord -stringbuilder $sb -job $Job -session $sess

                

            }

            write-reportmimicfootertable $sb -server (get-veeamserver)

            write-reportmimicfooter $sb



            #If you want to send the html as an email, you can use $content = $sb.ToString() to put the content in a variable. You should be able to use Send-MailMessage -BodyAsHtml -Body $content to actually send the message

            $sb.ToString() | Out-File -FilePath $File

        } else {

          Write-Error "Job can only be backup, backup copy or replication job. Cannot be $jt"  

        }

    } else {

       Write-Error "Can not find Job with name $JobName"

    }

} else {

  Write-Error "JobName is null"
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by tdewin »

there is actually a parameter called -max. Just do -max 1 if you want only the latest session
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by tdewin » 1 person likes this post

Ok new version has been merged in veeamhub : https://github.com/VeeamHub/powershell/ ... imicReport

You can now supply no jobname, in which case it will take just the latest session for every job (so you get a global job overview)
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by gveat »

Using this script. I found that when I use the -max variable of 1, The HTML page's header still lists "failed" if it previously failed at any time. In conjunction it will still show a red banner. Is there a way to change the way it calls for that info to also only look at the last session?
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by tdewin »

The issue is not 100% clear, could you potentially screenshot the issue? Also you can use the github to open up issue's, so they are centrally tracked and they will be more visible for us
gveat
Influencer
Posts: 23
Liked: 3 times
Joined: Sep 29, 2016 6:21 pm
Full Name: Greg Veater
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by gveat »

Thank you for the help on this. It helps us get one step closer to using Veeam throughout our environment.
s.strub

[MERGED] automatic tape session report or powershell

Post by s.strub »

Hello,

The Veeam Support asked if I could open a Feature Request for the Problem I have, so here it is:
The Subject says it already, I'm searching a function (e.g.: a powershell command) to create a Tape Session Report in Veeam, like clicking this Button:
Image
The Button creates a HTML document with all reports, which is not necessary but nice to have.
If you need any further information please let me know.

Regards

Seraphim
Shestakov
Veteran
Posts: 7328
Liked: 781 times
Joined: May 21, 2014 11:03 am
Full Name: Nikita Shestakov
Location: Prague
Contact:

Re: Generate Veeam Session Report (HTML) from Powershell

Post by Shestakov »

Hello Seraphim,
Could you specify the information you want to get in the report?
By the way, do you use Veeam ONE?
There are several predefined reports you may be interested in.
Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests