Here is a set of samples I used to do a common task in my scripting life. This go around I wanted to use Powershell.
A) Create a script to send emails in powershell
1) Open Powershell type set-executionpolicy Unrestricted
‘You’ll want to also look at using RemoteSignedType
2) Type Notepad myscript.ps1
3) Paste sample code and save in myscript.ps1
$SmtpClient = new-object system.net.mail.smtpClient
$SmtpServer = “localhost”
$To = [email protected]
$Title = “Subject Matter”
$Body = “Body Text”
1) Type ./myscript.ps1
‘Verify you receive the email.
1) Create a new scheduled task.
‘The syntax is to execute the script is:
powershell -command “& ‘SomeDirmyScript.ps1′”
2) Set the script to run as your normal task scheduler accounts.
3) Execute task, verify you receive the email
Hope this helps,