Dear sir,
I getting the SMTP error below consistently with 1 object in the Foreach pipeline. The others work fine and send the email. There is nothing wrong with the object itself. I put output to the console to see if is execution the if statement correctly which it is. I've tried both the .NET SMPT commands and the PS 4 Send-mailmessage. I've tried to use the dispose command with the .NET commands. All the objects use the same command and message to email.
Command line:
if((Test-Connection$_.ComputerName-quiet)-ne$true) {
Send-MailMessage-To$To-Subject$Subject-Body$BodyPing-SmtpServer$smtpServer-From$From
Write-Host"Ping down $($_.ComputerName)"
}
Error:
Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.4.2 service timed out.
At C:\safe\local\untested_script_host_file.ps1:89 char:9
+ Send-MailMessage -To $To -Subject $Subject -Body $BodyPing -SmtpServer $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
+ FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
Thank you, Brian