Hello !
am trying to gathers list of vms in a vc and send an email as HTML, i see script is executing but when it is sending report is blank.
help me in correcting this.
# Get date in UK format day/month/year
$date = Get-Date -Format dd/MM/yy
$Header = @"
<style>
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
</style>
"@
Connect-VIServer -Server vc -User -u admin -p admin
$Report = Get-VM | Where-Object {$_.Extensiondata.Runtime.ConsolidationNeeded} | Select Name, PowerState, UsedSpaceGB | ConvertTo-HTML -Head $Header
# Send email message
Send-mailmessage -to "xyz@abc.com" -from "zyx@abc.com" -subject "Disk consolidation needed" -body "Please find below vms requried disk consolidation , take necessary action." -BodyAsHtml -SmtpServer "10.1.2.3"
=============================
in email am receiving without data