Here is the finished product (for now).
Thanks for all the help LucD!!!!!
$CIservername = "Vcloudservername"
$UserID = "userID"
$password = "password"
Connect-Ciserver -Server $CIservername -User $UserID -Password $Password
$smtpServer = "exchange.server.com"
$ReportFrom = "yourname@domain"
$report = @()
$date = Get-Date
$vapp = "*"
foreach($Vapp in Get-CiVapp -Name $vapp){
$vm = $vapp | get-civm
if($vm) {
$vm | %{
$row = "" | Select "Name", "VApp", "Org", "Status", "Operating System", "CpuCount", "Memory (GB)", Owner
$row."Name" = $_.Name
$row."Vapp" = $Vapp #we know the vapp already
$row."Org" = $_.Org
$row."Status" = $_.Status
$row."Operating System" = $_.GuestOSFullName
$row."CpuCount" = $_.CpuCount
$row."Memory (GB)" = ($_ | Measure-Object -Property MemoryMB -Sum).Sum/1024
$row.Owner = $vapp.Owner
$report += $row
}
}
}
#Html style sheet
$a = "<style>"
$a = $a + "BODY{background-color:lavender;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:whitesmoke}"
$a = $a + "TD{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:slategrey}"
$a = $a + "</style>"
#sort by Org property
$report = $report | Sort-Object -Property Org
$report | export-csv "C:\VcloudVMs.csv" -NoTypeInformation -UseCulture
#html output
$report | ConvertTo-HTML -head $a -body "<H1>Vcloud Inventory Report</H1>
<p>
<a href='http://webserver.com/VcloudVMs.csv'>Download as CSV</a><br>
<font size='2' face='arial' color='red'>Last Updated: $date </font>
</p>" | Out-File "C:\VcloudInventroy.html"
Invoke-Expression C:\VcloudInventroy.html
$billiejean = "C:\VcloudVMs.csv"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($billiejean)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = $ReportFrom
$msg.To.Add("person.to.recieve@domain.com")
$msg.Bcc.Add("maybe.bcc.yourself?@domain.com")
$msg.Subject = "Vcloud VM report for $date"
$msg.Body = "Report Attached or you may view it at http://webserver.com/VcloudInventroy.html"
$msg.Attachments.Add($att)
$smtp.Send($msg)
$msg.Dispose()
Disconnect-CIServer -Server $CIserver -confirm:$False