I need some help here. I have the below Powershell code which I use to generate a HTML Table with Database Size and Names.
Now the output is good and everything looks better.. But sinew I have got over 500 Databases my boss has to scroll a lot to read the data,
I was thinking if there is a way I can put it in a column.
Something like this
Mbx001 MBX002 MBX003 MBX004
2.1 GB 3.2 GB 4.5 GB 10.8 GB
here is the power shell code
$dbreport = Generate-ReportHeader "dbreport.png" "$l_db_header"
$cells=@("$DB Name","Database Size")
$dbreport += Generate-HTMLTable "Database Overview" $cells
$databases = get-mailboxdatabase -status | sort
$currentDate = Get-Date
foreach ($database in $databases)
{
$dbname = $database.name
$dbserver = $database.server
$dbsize = $database.DatabaseSize
$pf = (Get-MailboxDatabase "$database" | get-mailbox -ResultSize Unlimited).count
$cells=@("$dbname","$dbsize")
$dbreport += New-HTMLTableLine $cells
$dbsizeges = $dbsizeges + $database.databasesize
$gespf = $gespf + $pf
$dbsizegb= $dbsize.Split(' ')[0]
$dbvalues += @{$dbname=$dbsizegb}
}
$dbreport += End-HTMLTable
$cells=@("DatabaseCount","Database Size","Database Overall Count")
$dbreport += Generate-HTMLTable "$l_db_summary" $cells
$anzdb = $databases.count
$cells=@("$anzdb","$dbsizeges","$gespf")
$dbreport += New-HTMLTableLine $cells
$dbreport += End-HTMLTable
new-cylinderchart 500 400 Database Name Size $dbvalues "$tmpdir\dbstat.png"
$dbreport += Include-HTMLInlinePictures "$tmpdir\dbstat.png"
$dbreport | set-content "$tmpdir\dbreport.html"
$dbreport | add-content "$tmpdir\report.html"
Here is the Functions File
#HTML Tables #-------------------------------------------------------------------------------------- # HTML Header function New-HTMLHeader ($title) { $HTMLHeader = "
<html>
<head>
<title>$title</title>
</head>
<body>
<div align=` "center`">
<table style=` "width: 90%; text-align: left; margin-left: auto; margin-right: auto; border-collapse:collapse; font-family:calibri;`" border=` "0`" cellpadding=` "0`" cellspacing=` "0`">
<tr>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; width: 100px`">
<img src=` "cid:reportheader.png`" alt=` "picture`">
</td>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; font-size: 20px`">Exchange Report</td>
</tr>
</table>
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
Exchange Report for $orgname
<br>Exchange Reporter
<br>
</tr>
</td>
</table>
"#" return $HTMLHeader } # Table function Generate-HTMLTable ($headline, $cells) { $HTMLTable = "
<h3 style=` "text-align:center; font-family:calibri; color: `#0072C6;`">$headline</h3>
<table style=` "width: 80%; text-align: left; margin-left: auto; margin-right: auto; border-collapse:collapse; font-family:calibri;`" border=` "0`" cellpadding=` "0`" cellspacing=` "0`">
<tr>"#" foreach ($cell in $cells) { $HTMLTable += "
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px;`">$cell</td>" } $HTMLTable += "</tr>" return $HTMLTable } # New Table function New-HTMLTableLine ($cells) { $NewTableLine = "
<tr>" foreach ($cell in $cells) { $NewTableLine += "
<td style=` "background-color: `#F8F8F8; color: `#585858; border:solid `#0072C6; border-width: 1px 1px 1px 1px;`">$cell</td>" } $NewTableLine += "</tr>" return $NewTableLine } # Table function End-HTMLTable () { $TableEnd = "</table>" return $TableEnd } # HTML End function End-HTML () { $HTMLEnd = "
</body>
</html>
" return $HTMLEnd } # HTML Inline Pictures function Include-HTMLInlinePictures ($picid) { $htmlreport = "
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<tr>
<td>
<center>
" $Pics = Get-ChildItem "$picid" -name Foreach ($pic in $Pics) { $htmlreport += "
<img src=` "cid:$pic`" alt=` "picture`">" } $htmlreport += "
</center>
</tr>
</td>
</table>
" return $HTMLReport } # Report Header function Generate-ReportHeader ($Image, $Headline) { $ReportHeader = "
<br>" $ReportHeader += "
<table style=` "width: 90%; text-align: left; margin-left: auto; margin-right: auto; border-collapse:collapse; font-family:calibri;`" border=` "0`" cellpadding=` "0`" cellspacing=` "0`">" $ReportHeader += "
<tr>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; width: 100px`">
<img src=` "cid:$image`" alt=` "picture`">
</td>
<td style=` "background-color: `#0072C6; color: `#ffffff; font-weight: bold; border:solid `#0072C6; border-width: 3px 3px 3px 3px; font-size: 20px`">$headline</td>
</tr>
</table>
" #" return $ReportHeader } # Report Footer function Generate-ReportFooter () { if ($language -match "DE") { $footer = "
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
Exchange Reporter $reporterversion
<br>
</td>
</tr>
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
<center>
<hr>Spenden Sie etwas für die Weiterentwicklung, wenn Ihnen Exchange Reporter gefällt:
<br>
</center>
</td>
</tr>
</table>
"#" return $footer } else { $footer = "
<table align=` "center`" cellspacing=` "0`" style=` "width: 80%`">
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
</td>
</tr>
<tr>
<td style=` "background-color: `#F8F8F8; color: `#585858;`">
<center>
<hr>
</center>
</td>
</tr>
</table>
"#" return $footer } }