Hi,
Once again I am stuck, I am trying to get the dns server info out and into the below report, all other parts are working but when I run the script I get the following in the column for DNS Servers.
System.String[]
If I just run the script by pasting into the VI toolkit it displays the following:
{192.168.2.1, 192.168.2.2}
This is what I would like when converted to HTML.
I do have two DNS servers, is this why and if so does that mean that if I had multiple entries for the other parts they also would not work.
Could somebody point me in the right direction??
Thanks again,
Dan
$Report = @()
$ESXHosts = Get-VMHost | Sort Name | Get-View
ForEach ($ESXHost in $ESXHosts)
{
$ReportObj = "" | Select Name, "Firewall Incomming Blocked", "Firewall Outgoing Blocked", "DNS Servers", "VMk Def Gateway", "SC Def Gateway"
$ReportObj.Name = $ESXHost.Name
$ReportObj."Firewall Incomming Blocked" = $ESXHost.config.firewall.defaultPolicy.incomingBlocked
$ReportObj."Firewall Outgoing Blocked" = $ESXHost.config.firewall.defaultPolicy.outgoingBlocked
$ReportObj."DNS Servers" = $ESXHost.config.network.dnsconfig.address
$ReportObj."VMk Def Gateway" = $ESXHost.config.Network.IpRouteConfig.DefaultGateway
$ReportObj."SC Def Gateway" = $ESXHost.config.Network.ConsoleIpRouteConfig.DefaultGateway
$Report += $ReportObj
}
$Report | ConvertTo-Html -title "Host Firewall, DNS and Default Gateways" -body "<H4>Host Firewall, DNS and Default Gateways</H4>" | Out-File -Append $filelocation
Try this.
$ReportObj."DNS1" = $ESXHost.config.network.dnsconfig.address[0]
$ReportObj."DNS2" = $ESXHost.config.network.dnsconfig.address[1]
Message was edited by: Zsoldier
Try this.
$ReportObj."DNS1" = $ESXHost.config.network.dnsconfig.address[0]
$ReportObj."DNS2" = $ESXHost.config.network.dnsconfig.address[1]
Message was edited by: Zsoldier
thats worked a treat, thank you again!