Share via


TCP Connection Blocked or Reset

Question

Thursday, March 24, 2016 2:39 PM

I posted a question about sending email via PowerShell from 2 Windows 10 Pro machines on our domain.  1 works and the other does not.  Below is a link of my original post with the responses from the community and the recommendation to repost.

 https://community.office365.com/en-us/f/148/p/436664/1110880#1110880

I understand I was directed to repost in Windows 10 to request assistance in identifying why a TCP connection would be blocked or reset.  

Below is the discussion:

Original Question:

I am attempting to email the results of a get-mailbox script using the send-mailmessage command.  

Below is a smaller subset of my overall script.  This script (and the larger script which gathers stats for us) both run successfully on my main Surface Pro 4 (Windows 10 64 bit) logged in as myself.  WIndows Firewall is enabled and  Symantec EndPoint Protection 12.1.6 RU6 MP1 build 6318 is running on this machine.

#Bare Bones EMail from Powershell

$userCred = Get-Credential
$to = "[email protected]"
$from = "[email protected]"
$smtpserver = "outlook.office365.com"
$subject = "Email Clutter Folder Size Review"
$body = "Attached is the weekly email clutter folder size review"

send-mailmessage -To $to -From $from -SmtpServer $smtpserver -UseSsl -Subject $subject -Body $body -Credential $userCred

When I run the above script on another another desktop - Windows 10 also logged in with the same Windows credentials I receive the below error.

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
send-mailmessage : Unable to connect to the remote server
At line:11 char:1

  • send-mailmessage -To $to -From $from -SmtpServer $smtpserver -UseSsl ...
  • CategoryInfo : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
  • FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage

I have disabled both WIndows Firewall and Symantec EndPoint Protection on this second machine with no success.  How can I isolate why this second machine is "unable to connect to the remote server?"

MSFT response after NetMon trace:

Thanks for the trace results.
After checking them, I find the TCP connection will be reset when trying to initial the TCP connection to the server.
Since the first machine works, it indicates that there is no issue on the server, I suggest you check if there is any specific setting which will block/reset TCP connection on the second machine.

Another Community Response:

Check whether you have proxy settings enabled for the second machine

Me:

Thank you both for your responses.  I checked "Network Proxy Settings" on the second machine (Windows 10 Pro 64 bit).  Under "Automatic Proxy Setup" the default of "Automatically detect settings" was on and "Use setup script" was off.  I disabled "Automatically detect settings".  Manual Proxy Setup was off. 

Attempted again with the same results as before.  (send-mailmessage: unable to connect to the remote server"

Next I fully uninstalled Symantec EndPoint Protection, disabled both Windows Defender and Windows Firewall, rebooted the machine, ran the powershell script again, and still receive the same error.

I am at the limit of my knowledge to troubleshoot why the TCP connection would block or reset the TCP connection.  Is there anything further specifically I should try or another forum who could assist further?

Community Response:

Have you checked whether you can connect OWA from the second machine?

Me:

Yes, I just confirmed I can connect OWA from the second machine.  I was able to login.microsoftonline.com and access my inbox.  

MSFT Response:

You can check the network settings such as firewall in the organization.
If there is no specific setting, I suggest you post the issue on our Windows 10 forum below:
https://social.technet.microsoft.com/Forums/en-us/home?category=WinPreview2014%2CWindows10ITPro&filter=alltypes&sort=lastpostdesc

What further information would be helpful in reposting this issue?  

Thank you,

Brent

All replies (5)

Friday, March 25, 2016 2:42 PM ✅Answered | 1 vote

Well the TcpTest is testing if port 25 is open, smtp, to that address. So that failing is the issue, you cannot connect to the smtp port of outlook.office365.com on this machine.

So will need to work out the differences between the working machine and non-working one. If you look at ipconfig -a (from a command prompt) on both machines what are differences?


Friday, March 25, 2016 4:44 PM ✅Answered | 1 vote

Is the other (failing) machine on the same network as the successful one?

Best regards George


Thursday, March 24, 2016 6:50 PM

So what does;

Test-NetConnection -ComputerName outlook.office365.com -Port 25 -InformationLevel Detailed

Show? Does it succeed?


Friday, March 25, 2016 1:31 PM

Mr Happy

TcpTestSucceeded: False

PingSucceeded: True

Thank you,

Brent


Friday, March 25, 2016 5:20 PM

George,

That was the problem.  I *assumed* they were on the same subnet, but indeed machine 2 was on our user vlan\subnet after I actually looked.  Once we brought machine 2 back over to the correct subnet the commands work perfectly.  

Thank you both for helping me troubleshoot this.

Respectfully,

Brent