Output Display

I have the below code:

$clusters=“pcclus4”, “pctclus7”

Foreach($cluster in $clusters)
$VMS += Get-VM –ComputerName (Get-ClusterNode –Cluster $cluster) |Where-Object { $.Name -like ‘FS’ }
$NoReplica=$VMS |where-object {$
.ReplicationState -eq “disabled”} |ft Name | Out-String
$text= “Servers without replica enabled in cluster $clusters are” + “`r`n” + $NoReplica
Send-MailMessage -To “lala@lala.com” -From “cluster@lala.com” -Subject “FS without Hyper-V Replica Enabled” -SmtpServer “lalamail.lala.com” -Body $text

I am getting a report on email looking like

HostName Name
-------- ---- tFS11 PC3FS21 PCADFS21 tFS16 PC7FS22

This output contains the FS from both clusters. I would like to get a report formatted on a table or at least to have the name of the cluster and then the FS then the other cluster and its FS below. For e.g.
FS on pcclus4
tFS11 PC3FS21

FS on pctclus7

You should look at the eBooks link above and read the free eBook Creating HTML Reports in PowerShell. You have a LOT more flexibility doing HTML reports rather than trying to build emails as a string. Try this:

$clusters="pcclus4", "pctclus7"

$vms = foreach($cluster in $clusters){
    Get-VM –ComputerName (Get-ClusterNode –Cluster $cluster) | 
    Where-Object { ($_.Name -like '*FS*') -and ($_.ReplicationState -eq "disabled")}

$body = $vms | ConvertTo-HTML -Title "Servers without replica enabled in cluster" | Out-String

$mailParams = @{
    To = "lala@lala.com" 
    From = "cluster@lala.com" 
    Subject = "FS without HyperV Replica Enabled" 
    SmtpServer = "lalamail.lala.com" 
    Body = $body

Send-MailMessage @mailParams

Not working like this only get an infinit message

Servers without replica enabled in cluster

Thank you!