Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 665
  • Last Modified:

Send-MailMessage

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>
0
mjkerrig
Asked:
mjkerrig
  • 2
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
make sure that the account used to run the script in the scheduled task have permission to send through your smtp server.
0
 
mjkerrigAuthor Commented:
I just found an article that put me on the right track.  Turns out that it is McAfee causing the issue.  It doesn't block the server calls out of ISE, but does block the requests out of standard powershell.
0
 
mjkerrigAuthor Commented:
Found an article that put me on checking the firewall for blocking powershell.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now