Hi guys,
I am tweaking the great ESX health script create created by Ivo Beerens.
I have downloaded and inserted the code that LucD put in a post to get the vm disk information, and i am trying to tweak this to output it to a constantly appending HTML file.
I can get it to insert the output into the file, but the formatting is all over the place. Does anyone have suggestions how to format it to have the headings VMName, Diskname and disk size just as it has in the powershell?
Thanks for any help
D
You can use the ConvertTo-Html cmdlet for creating HTML output.
Have a look at this example, it uses the ConvertTo-Html cmdlet in it's simplest format.
Have a look at the parameters for this cmdlet to further customise the produced HTML code.
$col = @() get-cluster | Get-VM | %{ $disks = $_ | Get-HardDisk foreach($hd in $disks){ $row = "" | select VMname, DiskName, DiskSize $row.VMname = $_.Name $row.DiskName = $hd.Filename $row.DiskSize = $hd.CapacityKb $col += $row } } $col |ConvertTo-Html > "C:\Disks.html"
Note: if you use the foreach statement there is no need to make a distinction between a single object and an array of objects.
The foreach statement does that for you. Something I also had to learn after I wrote that script
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You can use the ConvertTo-Html cmdlet for creating HTML output.
Have a look at this example, it uses the ConvertTo-Html cmdlet in it's simplest format.
Have a look at the parameters for this cmdlet to further customise the produced HTML code.
$col = @() get-cluster | Get-VM | %{ $disks = $_ | Get-HardDisk foreach($hd in $disks){ $row = "" | select VMname, DiskName, DiskSize $row.VMname = $_.Name $row.DiskName = $hd.Filename $row.DiskSize = $hd.CapacityKb $col += $row } } $col |ConvertTo-Html > "C:\Disks.html"
Note: if you use the foreach statement there is no need to make a distinction between a single object and an array of objects.
The foreach statement does that for you. Something I also had to learn after I wrote that script
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
In case you want to add multiple HTML tables to a single HTML file, try this function I wrote:
Function Create-HTMLTable { param([array]$Array) $arrHTML = $Array | ConvertTo-Html $arrHTML[-1] = $arrHTML[-1].ToString().Replace('',"") Return $arrHTML[http://5..1000|http://5..1000] }
Hugo
Thats solved it guys.
As usual the responses in this forum are awesome.
Keep up the good work guys. :smileygrin:
Cheers
D