Hi
I have the script below which LucD has helped a lot with, but I would like to be able to define the width of each table column so I can make their width specific to the content they contain. My script is as follows and it currently makes each column of equal width. Could someone please advise if I can configure the script to specify specific column widths:
$htmlvmdata = "<style>"
$htmlvmdata = $htmlvmdata + "BODY{background-color:peachpuff;}"
$htmlvmdata = $htmlvmdata + "TABLE{table-layout: fixed;width: 1500px;font-size:10px;border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse}"
$htmlvmdata = $htmlvmdata + "TH{text-align:center;border-width: 1px;padding: 10px;border-style: solid;border-color: black;background-color:thistle}"
$htmlvmdata = $htmlvmdata + "TD{text-align:center;border-width: 1px;padding: 10px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$htmlvmdata = $htmlvmdata + "BODY{display: block}"
$htmlvmdata = $htmlvmdata + "</style>"
$reportvmdata_html = @()
foreach ($dc in Get-Datacenter) {
foreach ($cluster in Get-Cluster -Location $dc){
$vms = Get-view -ViewType VirtualMachine -SearchRoot $cluster.ExtensionData.MoRef
foreach ($vm in $vms){
$infovmdata_html = "" | select Datacenter, Name, ToolsStatus, NumCpu, MemoryGB, guestos, IPAddress, Datastore, DatastoreUsedGB, CurrentESXHost
$infovmdata_html.IPAddress = ($vm.Guest.net.IPAddress | where{$_} | Sort-Object -Unique) -join "|"
$infovmdata_html.Datastore = (Get-View -Id $vm.Datastore -Property Name).Name -join "|"
$infovmdata_html.DatastoreUsedGB = [math]::Round(($vm.Storage.PerDatastoreUsage.Committed | Measure-Object -Sum).Sum/1GB,1)
$infovmdata_html.datacenter = $dc.name
$infovmdata_html.Name = $vm.name
$infovmdata_html.toolsstatus = $vm.guest.toolsstatus
$infovmdata_html.NumCpu = $vm.Summary.config.NumCpu
$infovmdata_html.MemoryGB = $vm.Summary.config.memorySizeMB / 1024
$infovmdata_html.guestos = $vm.guest.guestfullname
$infovmdata_html.CurrentESXHost = (Get-VMHost -VM $vm.name).Name
$reportvmdata_html += $infovmdata_html
}
}
}
($reportvmdata_html | Sort-Object -Property Datacenter,Name | ConvertTo-Html -Head $htmlvmdata -Body "<h1> Report run on: $Dateformat</h1><h2>Total number of VMs across all Data Centres/Clusters: $total_vms</h2>").Replace('|','<br/>') | Out-File $export_html_vmdata