My code is below and does the job well enough. However I would like to have the VM's list say 10 VMs, then start another "column" in the same row. Almost like make them bullets. A certain cluster could contain almost 100 VMs and having it list 100 VMs can be messy and sort of an eye strain.
Is this possible?
$a = "<style>"
$a = $a + "BODY{background-color:peachpuff;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"
$array = @()
$clusters = Get-Cluster | sort Name
Foreach ($cluster in $clusters)
{
$hosts = get-cluster -name $cluster | get-vmhost
$gethosts = ($hosts.Name | % { (get-vmhost $_).Name;}) -join ';';
$gethosts = $gethosts.Replace(';',"`r`n")
$vms = get-cluster -name $cluster | get-vm
$getvms = ($vms.Name | % { (get-vm $_).Name;}) -join ';';
$getvms = $getvms.Replace(';',"`r`n")
$vmCount = get-cluster -name $cluster | select Name, @{N=“NumVM“;E={($_ | Get-VM).Count}}
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "Cluster" -Value $cluster
$obj | Add-Member -MemberType NoteProperty -Name "Hosts" -Value $gethosts
$obj | Add-Member -MemberType NoteProperty -Name "Number of VMs" -Value $vmCount.NumVM
$obj | Add-Member -MemberType NoteProperty -Name "VMs" -Value $getvms
$array += $obj
}
$array |select Cluster, Hosts, "Number of VMs", VMs| ConvertTo-HTML -head $a| out-file c:\temp\test\ClusterInfo.html -force
In my current script, the VM's basically just are listed and do "fit the screen" and the row will adjust as needed. However, is there a better way to auto adjust and list VM's in a cleaner way?
Appreciate any help!