Generate Veeam Session Report (HTML) from Powershell

PowerShell script exchange

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby gveat » Mon Oct 03, 2016 12:10 pm

How do I output this to a file?
gveat
Influencer
 
Posts: 17
Liked: 2 times
Joined: Thu Sep 29, 2016 6:21 pm
Full Name: Greg Veater

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby PTide » Mon Oct 03, 2016 12:45 pm

You can use the Out-File PS cmdlet

Thanks
PTide
Veeam Software
 
Posts: 3019
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby gveat » Mon Oct 03, 2016 3:39 pm

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.
gveat
Influencer
 
Posts: 17
Liked: 2 times
Joined: Thu Sep 29, 2016 6:21 pm
Full Name: Greg Veater

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby PTide » Mon Oct 03, 2016 4:00 pm

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!
PTide
Veeam Software
 
Posts: 3019
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby gveat » Mon Oct 03, 2016 5:13 pm

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.
gveat
Influencer
 
Posts: 17
Liked: 2 times
Joined: Thu Sep 29, 2016 6:21 pm
Full Name: Greg Veater

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby tdewin » Tue Oct 04, 2016 12:00 pm

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
tdewin
Veeam Software
 
Posts: 1046
Liked: 361 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby gveat » Tue Oct 04, 2016 6:51 pm 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: 17
Liked: 2 times
Joined: Thu Sep 29, 2016 6:21 pm
Full Name: Greg Veater

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby gveat » Wed Oct 05, 2016 1:58 pm

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"
gveat
Influencer
 
Posts: 17
Liked: 2 times
Joined: Thu Sep 29, 2016 6:21 pm
Full Name: Greg Veater

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby tdewin » Wed Oct 05, 2016 2:46 pm

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

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby tdewin » Thu Oct 06, 2016 11:47 am 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)
tdewin
Veeam Software
 
Posts: 1046
Liked: 361 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby gveat » Fri Oct 21, 2016 12:24 pm

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?
gveat
Influencer
 
Posts: 17
Liked: 2 times
Joined: Thu Sep 29, 2016 6:21 pm
Full Name: Greg Veater

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby tdewin » Sat Oct 22, 2016 7:25 am

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
tdewin
Veeam Software
 
Posts: 1046
Liked: 361 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby gveat » Mon Oct 24, 2016 6:29 pm

Thank you for the help on this. It helps us get one step closer to using Veeam throughout our environment.
gveat
Influencer
 
Posts: 17
Liked: 2 times
Joined: Thu Sep 29, 2016 6:21 pm
Full Name: Greg Veater

[MERGED] automatic tape session report or powershell

Veeam Logoby s.strub » Tue Dec 06, 2016 12:49 pm

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
s.strub
Novice
 
Posts: 3
Liked: never
Joined: Wed Nov 30, 2016 9:51 am
Full Name: Seraphim Strub

Re: Generate Veeam Session Report (HTML) from Powershell

Veeam Logoby Shestakov » Tue Dec 06, 2016 12:55 pm

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!
Shestakov
Veeam Software
 
Posts: 4861
Liked: 396 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

PreviousNext

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests