I have made a simple report script, this script gives some reports about the job, and after it displays the message error.
I have made one filter in order to exclude a message error that i don't want to be displayed, the script works fine.
Here is the script:
$Session=Get-VBRBackupSession -Name "TestError" | Where {$_.Result -eq "Failed"}
foreach ($Session in $Sessions){
$StrError=$Session[0].logger.getLog().updaterecords
}
if($Session.getDetails() -notlike "*Failed to cal RPC function*") {
$Session.GetTaskSessions()
$Session
$Session.getBackupStats()
write-host ""
$Session.getDetails()
}
I have already tried adding |ConvertTo-HTML |Out-File ... but it just displays a blank html file
-
- Novice
- Posts: 6
- Liked: never
- Joined: Oct 04, 2019 1:15 pm
- Full Name: AAAA
- Contact:
-
- Veeam Vanguard
- Posts: 282
- Liked: 113 times
- Joined: Apr 20, 2017 4:19 pm
- Full Name: Joe Houghes
- Location: Castle Rock, CO
- Contact:
Re: Write my output to HTML (maybe with tables)
What you are looking for is nothing specific to Veeam, so I would suggest that you search for resources around reporting in PowerShell.
This book is a great guide specific to HTML reporting with PowerShell: https://leanpub.com/creatinghtmlreports ... powershell
This book is a great guide specific to HTML reporting with PowerShell: https://leanpub.com/creatinghtmlreports ... powershell
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
-
- Influencer
- Posts: 13
- Liked: 8 times
- Joined: Feb 18, 2019 6:34 pm
- Full Name: Scott Driver
- Contact:
Re: Write my output to HTML (maybe with tables)
Hey @Dexiner
I just posted a script in the forum that makes use of convertto-html. It's a little funky to get use to. Honestly, while debugging I'd remove the " | out-file ..." and just send it straight to screen. If you get HTML, then you know you need to focus on the out-file. If you don't, then you honestly probably have problems with your variable objects that you're outputting.
Here's the script I used: powershell-f26/updated-veeam-backup-rep ... 63698.html
Here's some resources I used effectively:
fragments: https://devblogs.microsoft.com/scriptin ... and-files/
Formatting derived from here: https://4sysops.com/archives/building-h ... rtto-html/
Another format helper: http://techgenix.com/html-reports/
Lastly, pay attention to the data that's being output. I had to tinker around with whether I was trying to output an object or a string.
Best of luck! Please share back whatever you land on.
Relevant code snip from my report(v2) script
I just posted a script in the forum that makes use of convertto-html. It's a little funky to get use to. Honestly, while debugging I'd remove the " | out-file ..." and just send it straight to screen. If you get HTML, then you know you need to focus on the out-file. If you don't, then you honestly probably have problems with your variable objects that you're outputting.
Here's the script I used: powershell-f26/updated-veeam-backup-rep ... 63698.html
Here's some resources I used effectively:
fragments: https://devblogs.microsoft.com/scriptin ... and-files/
Formatting derived from here: https://4sysops.com/archives/building-h ... rtto-html/
Another format helper: http://techgenix.com/html-reports/
Lastly, pay attention to the data that's being output. I had to tinker around with whether I was trying to output an object or a string.
Best of luck! Please share back whatever you land on.
Relevant code snip from my report(v2) script
Function Build-Output{
$OutputFile="VeeamBackupOverview_$(get-date -Format HHmm_ddMMMyy)."
switch ($OutputType){
"HTML"{
$Header=
@"
<style>
table {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
TD {border-width: 1px;
padding: 3px;
border-style: solid;
border-color: black;}
</style>
"@ ## Must remail left aligned, no whitespace allowed before string terminator
$OutputFile=$OutputFile+"html"
$OverviewFrag= $VBRjobsOverviewResults | ConvertTo-Html -As Table -Fragment -PreContent '<h2>Overview Report</h2>'|Out-String
$HistoryFrag= $VBRjobsHistoryArray | ConvertTo-Html -As Table -Fragment -PreContent '<h2>History Overview Report</h2>'|Out-String
$GapFrag = $GapResults | ConvertTo-Html -As Table -Fragment -PreContent '<h2>Gap Report</h2>'|Out-String
ConvertTo-Html -Head $Header -PostContent $OverviewFrag,$HistoryFrag,$GapFrag|Out-File $OutputFile
}
}
}
Vanguard** | vExpert**** | VCP-DCV***** | VirtualVT.wordpress.com | @VTsnowboarder42
Lover of my family, snowboarding, community and bullet points.
Lover of my family, snowboarding, community and bullet points.
Who is online
Users browsing this forum: No registered users and 11 guests