Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 222846

Re: Diskconsolidation send email as HTML is blank

$
0
0

Try like 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

if($report-ne$null){

   $report=$report|ConvertTo-HTML-Head $Header|Out-String

}

else{

   $report='No VMs disk consolidation is required'

}


# Send email message

$sMail=@{

   To="xyz@abc.com"

   From="xyz@abc.com"

   Subject="Disk consolidation needed"

   Body=$report

   BodyAsHtml=$true

   SmtpServer="10.1.2.3"

}


Send-mailmessage@sMail


Viewing all articles
Browse latest Browse all 222846

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>