This script is designed to Execute a VBS script and then use Powershell to e-mail the VBS created report.
To use this script copy the contents of the script into notepad and save the file as FileName.ps1
Remember that in order to run scripts you may need to change the Powershell Execution Policy.
The following variables will need to be changed:
1. Copy the script:
Copy the script and place the script in whatever directory that you will execute it from.
3. Run the script:
Run the script using cscript to send the email notification.
cscript.exe "C:\Scripts\ScriptName.vbs"
This script can be copied as is. The top half containing fields such as from, to, subject, body, attachments, and the smtp server will need to be modified before execution.
$Date = get-date
$From = "[email protected]"
$To = "[email protected]"
$Subject = "Weekly Log Report - $Date"
$Body = "Please browse the included report for a list of Log files that have reached the set retention period and have been deleted"
$FileAttach = "C:\Scripts\LogReport.txt"
$SMTPServer = "exchange-server.somedomain.com"
$Attachment = new-object Net.Mail.Attachment($FileAttach)
$SMTP = new-object Net.Mail.SmtpClient($SMTPServer)
$MSG = new-object Net.Mail.MailMessage($From, $To, $Subject, $Body)
$MSG.attachments.add($Attachment)
$SMTP.send($msg)