Hi guys!
I run a script of mine on a fileserver 2008 R2; the script return a report in html but it's huge (50000 KB) so it takes a lot of time to load and i can't order it.
The function that create the html report is this:
Function Get-Report{
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True,Position=0)]$Drives,
[Parameter(Mandatory=$True,Position=1)][string]$Kind,
[Parameter(Mandatory=$True,Position=2)]$Source
)
$Today = Get-Date -Format "dd-MMM"
$Head = @"
<Title>$Kind Report</Title>
<style>
body {
background-color:#FFFFFF;
font-family:Verdana;
font-size:12pt;
}
td, th {
border:1px solid blue;
border-collapse:collapse;
}
th {
color:white;
background-color:green;
}
table, tr, td, th { padding: 5px; margin: 0px }
table { margin-left:50px; }
</style>
"@
[xml]$html = $Drives | ConvertTo-Html -fragment
for ($i=1;$i -le $html.table.tr.count-1;$i++) {
$class = $html.CreateAttribute("class")
}
$Body = @"
<H1>$Kind File Report for $Source</H1>
$($html.innerxml)
"@
$Log = $Kind + "Report" + $Today
if(!(Test-Path -Path "C:\Powershell Reports")){
New-Item -Path "C:\Powershell Reports" -ItemType directory
}
ConvertTo-HTML -head $head -PostContent "<br><i>$(Get-date)</i>" -body $body |
Out-File "C:\Powershell Reports\$Log.html" -Encoding ascii
}
And this is the output.Does anyone knows some easy function to convert and save the html output to an excel file keeping this structure?
Thanks!
A


