1

I am able to run the below sample script from command line when on the box but facing issues while attempting to run the same script from controlm.

# mailtest.ps1
$cmd='Send-MailMessage -Body "body" -To "to@abc.com" -From "from@abc.com" -Subject "subject" -SmtpServer "smtpserver.net" -Port 25
Invoke-Expression $cmd

Command line - working fine:

powershell -NoLogo -NonInteractive -File mailtest.ps1

ControlM - Error:

powershell -NoLogo -NonInteractive -File mailtest.ps1

Send-MailMessage : Unable to read date from the transport connection: net_io_connectionclosed
...
+ FullyQualifiedErrorId : SmtpException,Microsoft.Powershell.Commands.SendMailMessage

The network is behind firewall but I think that is not an issue here as the mail is being sent from command line without any issues.

What I have tried so far:

  • Have enabled client/server for TLS 1.0,1.1,1.2 & SSL 2.0,3.0
  • Have tried the port numbers - 25, 587 and 465 - none of them works in controlM
  • Have tried invoking using -NoProfile and Bypass arguments as well

Any pointer on what I am missing here will be great help.

Soumya
  • 885
  • 3
  • 14
  • 29

1 Answers1

0

This doesn't appear to be a Control-M issue (although running PowerShell scripts can be problematic via Control-M due to the restrictive nature of Windows).

Is the Control-M script being launched on the same Agent as where you are running the manual command line from?

As a test, I suggest checking the SMTP server properties and setting the IP Address to "All unsigned" and see if this clears the issue.

Back on the Control-M side, the recommended way to launch PowerShell scripts is to have a cmd file that points to the ps1 -

powershell -command "& { <file.ps1> ; exit $lastexitcode }"