Since the script already produces HTML, there is no need to do the ConvertTo-Html.
The following are in fact some HTML remarks:
- The data needs to go with the <td> tag, not <th> which is only for the header of the table
- And you have to indicate what the rows are with <tr>
Something like this for example
$VMInfo= @()
$VMInfo+="<table>"
$VMInfo+="<tr><th><center>VM Name</th><th><center>IP Address</th></tr>"
Get-VM-Namedb1-PipelineVariablevm|
ForEach-Object-Process {
$_.guest.IPAddress |
ForEach-Object-Process {
$VMInfo+="<tr><td><center>$($vm.Name)</td><td><center>$($_)</td>"
}
}
$VMInfo+="</table>"
$VMInfo|Set-Content-Path.\report.html
Invoke-Item-Path.\report.html