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

Re: Powershell/PowerCLI Dynamic Email Message Body with Datastores

$
0
0

The "@ has to be at the very start of the line in order  to work

 

here is a version without CSS...

 

Function Report-Datastore {

 

 

    $output = @()

 

 

    Get-Datastore | % {

        $props = [ordered]@{'Name'=$_.Name;

                            'UsedSpace'=[math]::Round(($_.CapacityGB - $_.FreeSpaceGB),2);

                            'PercFree'=[math]::Round((100 * ($_.FreeSpaceGB/$_.CapacityGB)),0)}

        $output += New-Object -TypeName PSCUstomObject -Property $props

    }

$output

}

 

 

$msg.Subject = "vCenter Datastore Health CompanyvCenter"

 

 

Connect-VIServer $vcserver

 

 

$html_DS = Report-Datastore |

           Sort-Object PercFree |

           ConvertTo-HTML -Fragment |

           Out-String

$html_DS = "<h2>Datastores</h2>$html_DS"

 

 

$params = @{'Head'="<title>vCenter Datastore Health CompanyvCenter</title>";

            'PreContent'="<h1>Datastore HealthCheck CompanyvCenter</h1>";

            'PostContent'=$html_DS}

 

 

$msg.Body = ConvertTo-HTML @params

$msg.Attachments.Add($att1)

$msg.IsBodyHTML = $true

$smtp.Send($msg)

$att1.Dispose()

 

 

Disconnect-VIServer $vcserver -Confirm:$false


Viewing all articles
Browse latest Browse all 232894

Trending Articles



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