I have a small project to convert all my powershell scripts to send the emails with the output in the body of the email was being sent as an attachment we are trying to limit the attachments on the email system I been successful on many but ran into two that I need expert help on I will post the other later.
My script that I am reworking
$LogFolder="c:\util\logs"
remove-item-path$LogFolder\tgcsnetdfs.*-Force
remove-item-path$LogFolder\tgcsnetrep.*-Force
remove-item-path$LogFolder\tgcsnetdocdfs.*-Force
remove-item-path$LogFolder\tgcsnetnote.*-Force
dfsradminhealthnew/rgname:tgcsnetrep/refmemname:tgcs012/ReportName:C:\UTIL\LOGS\TGCSNETREP
dfsradminhealthnew/rgname:our.network.tgcsnet.com\tgcsnetdfs\homedirectories/refmemname:tgcs012/ReportName:C:\UTIL\LOGS\TGCSNETDFS
dfsradminhealthnew/rgname:our.network.tgcsnet.com\tgcsnetdfs\documentation/refmemname:tgcs012/ReportName:C:\UTIL\LOGS\TGCSNETDOC
dfsradminhealthnew/rgname:our.network.tgcsnet.com\tgcsnetdfs\technotes/refmemname:tgcs012/ReportName:C:\UTIL\LOGS\TGCSNETNOTE
$Server=hostname
$Params= @{
Subject ="DFS Health Report for $Server"
Body ="$bigbody"
From ="no-reply@tgcsnet.com"
To ="systems-alert@tgcsnet.com"
smtpserver ="InternalRelay.TGCSNET.COM"
}
Send-MailMessage@Params
This script outputs the reports as .html files and I was using this before as you can see the attachments.
ANY WAY to get the reports in the body? Thank you Tom
If the command generates a file rather than console output wouldn’t we want to look at importing the content of that file? Unless of course we can redirect that output to the console, then we could capture it in a variable. Might I suggest looking into The “Get-Content” and “ConvertTo-HTML” Cmdlets?
Glad to hear that my suggestion at looking into the Get-Content Cmdlet, in conjunction with the previous suggestion of using the -BodyAsHTML switch parameter helped to get you were you needed to be!