Through the use of several code snippets here and in VMware's website, I've created the following code that works:
Connect-ViServer server
$body = Get-Folder -name vm | Get-VM | Get-Snapshot | Select Name, VM, SizeMb, Created | Out-String
send-mailmessage -From "myemail.com" -To "myemail.com" -SmtpServer "myserver.com" -Body $body -Subject "Snapshot Report"
The output that I get from this looks like this:
Name VM SizeMB Created
---- -- ------ -------
snapshot name server ...3507232666015625 11/6/2013 11:53...
snapshot name server ...4918060302734375 11/6/2013 10:30...
snapshot name server... ...0483551025390625 11/6/2013 10:32:...
snapshot name server ...2000579833984375 11/6/2013 3:58:34 PM
I figure there has to be a way to format the output to where it will accurately show the size in megabytes with a max of just 3 decimals and display the entire time created. My problem I know is somewhere here:
| Select Name, VM, SizeMb, Created | out-string
Does anyone know how to format output from Select
in order to specify just a max of 2-3 digit decimals?