0

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!

1
  • You should post an example of your current output and an example of what you want the output to be like. Commented Jan 27, 2015 at 18:56

1 Answer 1

1

I'd recommend to leave the table as it is and define a style with alternating row colors:

$a = @"
<style>
BODY {
  background-color:peachpuff;
}
TABLE {
  border-width: 1px;
  border-style: solid;
  border-color: black;
  border-collapse: collapse;
}
TH {
  border-width: 1px;
  padding: 0px;
  border-style: solid;
  border-color: black;
  background-color:thistle
}
TR:nth-child(odd) {
  background-color: lightgray;
}
TR:nth-child(even) {
  background-color: white;
}
TD {
  border-width: 1px;
  padding: 0px;
  border-style: solid;
  border-color: black;
  background-color:palegoldenrod
}
</style>
"@
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.