function Get-VAMIDNSServer{
$Type = "application/json"
for($i=0; $i -le ($VAMIIPs.Count -1); $i++)
{
$IP = $VAMIIPs[$i]
$BaseURL = "https://" + $ip + "/rest/"
$URI = $BaseURL+"appliance/networking/dns/servers"
$Session = @{
‘vmware-api-session-id’ = $Sessions[$i]
}
Try
{
$DNStmp = Invoke-RestMethod -Method Get -Uri $URI -TimeoutSec 100 -Headers $Session -ContentType $Type -SkipCertificateCheck
$DNSservers = $DNStmp.value.servers
#Object array for all DNS Servers.
$DNSObj = New-Object PSObject -Property @{
VAMIIP = $IP
DNSServers = $DNSservers
}
}# End Try Statement
Catch
{
$_.Exception.ToString()
$error[0] | Format-List -Force
} #End catch statement.
$VAMIDNS += $DNSObj
} #End For Loop
#$VAMIDNS += $DNSObj
return $VAMIDNS, $DNSObj
}
When Get-VAMIDNSServers returns $VAMIDNS it output the below as expected in Get-VAMISettings function.
DNSServers VAMIIP
---------- ------
{**.**.**.225} **.**.**.54
{**.**.**.218, ***.**.**.156, **.**.***.225, **.***.**.227} **.**.**.100
{**.***.**.218} **.**.**.101
{**.**.**.218} **.**.**.102
{**.**.**.218} **.**.**.102
[/quote]
Unfortunately this doesn't translate to html when using "ConvertTo-HTML"
[quote] $Output += $VAMIDNS | ConvertTo-HTML -Fragment -AS Table -PreContent "<H2>VAMI DNS Servers</h2>" | out-string [/quote]
Above Command gives me "System.Object" instead of DNS servers in table. Below is output for example.
<H2>VAMI DNS Servers</h2>
<table>
<colgroup><col/><col/></colgroup>
<tr><th>VAMIIP</th><th>DNSServers</th></tr>
<tr><td>********.54</td><td>System.Object[]</td></tr>
<tr><td>**********.100</td><td>System.Object[]</td></tr>
<tr><td>*************101</td><td>System.Object[]</td></tr>
<tr><td>***********102</td><td>System.Object[]</td></tr>
</table>
Anyone have any suggestion on how to get correct output to HTML format?