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

Re: report for multiple vms that are created

$
0
0

Try something along these lines

 

Function Create-HTMLTable {

    param([array]$Array)

    $arrHTML = $Array | ConvertTo-Html

    $arrHTML[-1] = $arrHTML[-1].ToString().Replace(‘</body></html>’,"")

    Return $arrHTML[5..2000]

}

 

$output = @()

$output += '<html><head></head><body><style>table{border-style:solid;border-width:1px;font-size:8pt;background-color:#ccc;width:100%;}th{text-align:left;}td{background-color:#fff;width:20%;border-style:solid;border-width:1px;}body{font-family:verdana;font-size:12pt;}h1{font-size:12pt;}h2{font-size:10pt;}</style>'

$output += ‘<H2>The vms that were created</H2>'

$output += ‘<H2> </H2>'

 

foreach($var in $vmlist){

    # script here

 

    ######################## Create and Send Email Report - Start ###############################################

    #

    #$Report = @()

    $Report = New-Object -TypeName system.collections.arraylist

    foreach ($vm in get-vm -Name $var.myvms )

    {

        #

        $report.add($reportedvm)|out-null

    }

    #

}

 

if ($HTML -eq "yes") {

    $output += '<p>'

    $output += '<p>'

    $output += Create-HTMLTable $report $output += '</p>'

    $output += '</body></html>'

    $output | Add-Content $FileHTML

}

 

if ($SendEmail -eq "yes") {

    $body = Get-Content $FileHTML | out-String

    Send-MailMessage –From $EmailFrom –To $EmailTo –Subject $EmailSubject –SmtpServer $EmailSMTP -Body $body -BodyAsHtml

}


Viewing all articles
Browse latest Browse all 234493

Trending Articles



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