Willie2232
asked on
Power Shell script to send a report.
Howdy Everyone!
I asked a question a few days ago and got awsome help so was wondering if anyone would be able to help me with this problem I am having now. I wrote\copyed this script and input\edited my data in to it but I get nothing but errors. Could some one look this over and give some input?
Thanks!
P.S. Substitute USERNAME and SERVERNAME with real people \ server
Will Jones
I asked a question a few days ago and got awsome help so was wondering if anyone would be able to help me with this problem I am having now. I wrote\copyed this script and input\edited my data in to it but I get nothing but errors. Could some one look this over and give some input?
Thanks!
P.S. Substitute USERNAME and SERVERNAME with real people \ server
Will Jones
###Send mailbox statistics script
###First, the administrator must change the mail message values in this section
$FromAddress = USERNAMEr@goodfellowbros.com
$ToAddress = USERNAME@goodfellowbros.com
$MessageSubject = "Mailbox Size Report"
$MessageBody = "Attached is the current list of mailbox sizes."
$SendingServer = "SERVERNAME.goodfellowbros.com"
###Now get the stats and store in a text file
Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft '
DisplayName,@{label="TotalItemSize(KB)";expression={$_.TotalItemSize.Value.ToKB()}}, '
ItemCount > mailboxes.txt
###Create the mail message and add the statistics text file as an attachment
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress,
$MessageSubject, $MessageBody
$Attachment = New-Object Net.Mail.Attachment("./mailboxes.txt")
$SMTPMessage.Attachments.Add($Attachment)
###Send the message
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.