The reason you are not seeing all the snapshots is because your loop stops when either the snapshots or the cdroms are done.
Suppose you have 3 entries for the snapshots and 2 for the cdroms, you will only get 2 lines of each.
I would do it something like this
if (($Snapshots-eq"yes") -or ($cdroms-eq"yes")) {
$array0=@()
$array1=@()
$array2=@()
$array3=@()
start-sleep1
connect-VIServer$vcserver
$vms=Get-VM
$snaps=$vms|Get-Snapshot
$array0=$snaps|%{$_.VM.Name}
$array1=$snaps|select-object-expandpropertyName
$array2=$snaps|select-object-expandpropertyCreated
$array3=@($vms|where { $_|Get-CDdrive|where { $_.ConnectionState.Connected-eq"true" } } |Select-object-ExpandPropertyName)
# Header
$msg.Body+="<FONT COLOR=black>VMware HealthCheck vCenter2</FONT><BR><BR>"
# Snapshot header
$msg.Body+="<B><FONT COLOR=black>Snapshots Active</FONT></B><BR>"
$msg.Body+="<B><FONT COLOR=black>VM Name</FONT></B><B><FONT COLOR=black>Name</FONT></B><B><FONT COLOR=black>Created</FONT></B>"
# Snapshots
0..($array0.Count-1) |%{
$msg.Body+="<BR><FONT COLOR=Red>"+$array0[$_]
$msg.Body+="</FONT><FONT COLOR=Red>"+$array1[$_]
$msg.Body+="</FONT><FONT COLOR=Red>"+$array2[$_] +"</FONT><BR><BR>"
}
# CDRom header
msg.Body+="<B><FONT COLOR=black>CDROMS Connected (Bad Habit)</FONT></B><BR>"
# CDRoms
$array3|%{
$msg.Body+="<B><FONT COLOR=black>VM Name</FONT></B><BR>"+"<FONT COLOR=Red>"+$_+"</FONT>"
}
}
Note that I didn't check if the HTML spacing and layout is still like you wanted it. You might need to add some spacing.