Posted on 2013-06-19
I have a question relating to sending SMTP email from powershell. I have written a short command that pulls information out of o365 and emails it to a group of people. The script works when I run it out of the ISE, but when I try and automate it as a task it fails in powershell.exe. The command comes back with cannot connect to smtp server.
Is there generally an extra switch that needs to be added to a send-mailmessage command to make it connect to a SMTP server that isn't needed when sending through ISE?
Abbreviation of command I am using:
Send-MailMessage -from <name> -to <names> -Subject "Daily License Count" -Body (function | Out-String) -SmtpServer <server>