Hi,
for licensing purposes I need to gather a report on host and socket information per host.
I want the report to include the following:
- Show host information per cluster (attached script).
- A headline with clustername per cluster
- The total number of sockets per cluster
I guess my problem is that I'm working in an array and I want to insert empty lines and headlines and my tries have not been successful so far. I'm not sure if I should convert to html and alter the layout that way. (hope not)
I'd appreciate any help...
/Kim
Hi Kim,
Welcome to the VMware Communities.
I have modified your script to include a header line per cluster with the name and the total number of sockets for the cluster:
$clusters = get-cluster | sort name $vms = $null if(test-path report.htm) { remove-item report.htm } foreach ($cluster in $clusters){ $report = @() $ClusterSockets = 0 foreach ($ESXHost in ($cluster | Get-VMHost | Sort Name)){ $row = "" | Select Name, Version, Build, ClusterName, Model, ProcessorType, Sockets, Cores, PNics $row.name = $ESXHost.name $row.version = $ESXHost.version $row.build = $ESXHost.build $row.clustername = $cluster.name $row.model = $ESXHost.model $row.ProcessorType = $ESXHost.ProcessorType $row.sockets = ($ESXHost | Get-View).Hardware.CpuInfo.NumCpuPackages $ClusterSockets += $row.sockets $row.cores = ($ESXHost | Get-View).Hardware.CpuInfo.NumCpuCores $row.PNics = ($ESXHost | Get-View).Config.Network.Pnic.Count $report += $row } # End foreach host "<h1>$($Cluster.Name), Number of sockets: $ClusterSockets</h1>" | Out-File report.htm -append $report | ConvertTo-HTML | Out-File report.htm -append } # End foreach cluster .\report.htm
Regards, Robert
Hi Kim,
Welcome to the VMware Communities.
I have modified your script to include a header line per cluster with the name and the total number of sockets for the cluster:
$clusters = get-cluster | sort name $vms = $null if(test-path report.htm) { remove-item report.htm } foreach ($cluster in $clusters){ $report = @() $ClusterSockets = 0 foreach ($ESXHost in ($cluster | Get-VMHost | Sort Name)){ $row = "" | Select Name, Version, Build, ClusterName, Model, ProcessorType, Sockets, Cores, PNics $row.name = $ESXHost.name $row.version = $ESXHost.version $row.build = $ESXHost.build $row.clustername = $cluster.name $row.model = $ESXHost.model $row.ProcessorType = $ESXHost.ProcessorType $row.sockets = ($ESXHost | Get-View).Hardware.CpuInfo.NumCpuPackages $ClusterSockets += $row.sockets $row.cores = ($ESXHost | Get-View).Hardware.CpuInfo.NumCpuCores $row.PNics = ($ESXHost | Get-View).Config.Network.Pnic.Count $report += $row } # End foreach host "<h1>$($Cluster.Name), Number of sockets: $ClusterSockets</h1>" | Out-File report.htm -append $report | ConvertTo-HTML | Out-File report.htm -append } # End foreach cluster .\report.htm
Regards, Robert
Thanks a lot, it's exactly what I need...
/Kim