VMware Cloud Community
DZ1
Hot Shot
Hot Shot

I'm on an HTML roll, but I have a general question.



I have a report gathering various information about ESXi hosts.  For the most part, everything is working, except there was one area that gave me a problem at first.


$Report.WWN = $VMHost | Get-VMHostHba -Type Fibrechannel | select @{ N="WWN"; E={ "{0:X}" -f $_.PortWorldWideName } } 

When the above line was output to html, it showed , instead of the 2 WWN for the HBA.  With some editing I changed it to



($Report.WWN = $VMHost | Get-VMHostHba -Type Fibrechannel | select @{ N="WWN"; E={ "{0:X}" -f $_.PortWorldWideName } } | Select -Expand WWN).split("")


Now, the data outputs, but the the split does not occur, the WWN shows side-by-side like this:  00000 00000, I want it to show with the top and bottom split


00000


00000


The short version I used to play with getting the WWN to show correctly is:


$arrVMHosts | Foreach {


$VMHost = $_


$Report = "" | Select HostName, WWN


$Report.Hostname = $Network.HostName


($Report.WWN = $VMHost | Get-VMHostHba -Type Fibrechannel | select @{ N="WWN"; E={ "{0:X}" -f $_.PortWorldWideName } } | Select -Expand WWN).split("")


  }


$AllReport | ConvertTo-Html -As Table -Head $custom -Body "<h2>The last update was on: $(Get-Date)</h2>" | Out-File c:\Folder\folder\Name.html


I guess my 2 questions are:


How can I show the WWN with the split in the HTML output?

How do you generally handle issues in HTML when the output shows ?  Do you just include ?



Overall, everything is working out and looking good, thanks for the help.

0 Kudos
3 Replies
ssbkang
Enthusiast
Enthusiast

Not sure I understood your question correctly but you can try the following:

$output = foreach ($esxi in (Get-Cluster -Name "Name of the cluster" | Get-VMHost | Sort Name)) { $esxi | Select Name, @{N="WWN";E={[string]::Join(",", (Get-VMHostHba -Type Fibrechannel | %{"{0:X}" -f $_.PortWorldWideName}))}}}

$output | ConvertTo-Html  -As Table -Head $custom -Body "<h2>The last update was on: $(Get-Date)</h2>" | Out-File "Location"

0 Kudos
DZ1
Hot Shot
Hot Shot

Thanks for the response, I realize that I was really all over the place.  The attached file is partial output of what I want. The two WWNs are side-by-side, but I want them top and bottom, just so it looks better in the HTML output. 

example.PNG

0 Kudos
ssbkang
Enthusiast
Enthusiast

Gotcha, try this:

$output = foreach ($esxi in (Get-Cluster -Name "Cluster Name"  | Get-VMHost | Sort Name)) { $esxi | Get-VMHostHBA -Type Fibrechannel | ForEach-Object { $_ | Select @{N="ESXi";E={$esxi.Name}}, @{N="WWN";E={%{"{0:X}" -f $_.PortWorldWideName}}}}}

$output | ConvertTo-Html  -As Table -Head $custom -Body "<h2>The last update was on: $(Get-Date)</h2>" | Out-File "Location"

0 Kudos