Hi All,
I want to send the report over email as an attachment after exporting the report into csv format. Any pointers or help will be much appreciated.
Note:- I'll send the data store report on a regular basis through window tasks scheduler.
Get-Datastore |
Select-Object Name,
@{N = ”FreespaceGB”; E = { “{0:n2}” -f ($_.FreespaceGB) } },
CapacityGB,
@{N = ”Provisioned”; E = { “{0:n2}” -f ($_.CapacityGB – $_.FreespaceGB + ($_.extensiondata.summary.uncommitted / 1GB)) } },
@{N = 'Used Space(%)'; E = { [math]::Round((($_.CapacityGB - $_.FreeSpaceGB) / $_.CapacityGB * 100), 1) } } |
Export-Csv -path c:\Temp\dsreport.csv -NoTypeInformation -UseCulture
Send-MailMessage -From 'User01 ' -To 'autoreports@xyz.com ', 'User03 ' -Subject 'Sending the Attachment' -Body "Forgot to send the attachment. Sending now." -Attachments .\C:\Temp\DSreport.csv -Priority High -DeliveryNotificationOption OnSuccess, OnFailure -SmtpServer 'smtp.fabrikam.com'
Thanks
V