The first thing you need to do is make sure that
Powershell is set to execute Powershell scripts, instead of only allowing
interactive commands to be run in the Powershell environment.
set-executionpolicy RemoteSigned
To run the script from command line:
powershell -command "&
c:\temp\test.ps1"
To send mail:
$SMTPClient = new-object
System.Net.Mail.smtpClient
$SMTPClient.host =
"localhost"
$MailMessage = new-object
System.Net.Mail.MailMessage
$MailMessage.From = "me@email.com"
$MailMessage.To.add("you@email.com")
$MailMessage.Subject = "Test
from powershell"
$MailMessage.Body = "Text
body"
$SMTPClient.Send($MailMessage)
No comments:
Post a Comment