Test-NetConnection - Anyway to not do the ping test when testing a specific port?

Hi,

Is there a way to have Test-NetConnection not perform a ping test ? I am only trying to check if a specific port is opened and can't seem to find the option to remove the ping test.

RemotePort             : 53
InterfaceAlias         : Ethernet
SourceAddress          : 10.1.0.30
PingSucceeded          : False
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded       : True

Above a typical case where I know ping will fail and I'd rather not spend the time waiting for a timeout or getting a nifty warning message especially when running this in a bigger script. When you are testing thousands of firewall rules, the ping test requires time which increases the runtime of the script (by a LOT).

Regards,

September 3rd, 2015 3:14pm

Hi,

Based on the docs, it looks like the answer is no:

https://technet.microsoft.com/en-us/library/dn372891(v=wps.630).aspx

I think I have something in my script vault that might help you. I'll post back if I fi

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 3:21pm

Thanks, thanks for confirming I did not mis read that TechNet doc. Might have been a hidden parameter :) It would be nice if they made it a parameter.

And thanks for the script, should be faster than the current way I do it.

Regards,

Edit:

$commandTCP = {
    param($1,$2);
    try {
        $null = New-Object System.Net.Sockets.TCPClient -ArgumentList $1,$2;
        $true;
    } catch {
        $false;
    }
} 

is faster than:

$commandTCP = {
    param($1,$2);
    test-netconnection -computername $1 -port $2 -informationlevel quiet;
} 

at least for me

Sweet and thanks again

  • Edited by O.Ragain 11 hours 22 minutes ago
September 3rd, 2015 3:38pm

Thanks, thanks for confirming I did not mis read that TechNet doc. Might have been a hidden parameter :) It would be nice if they made it a parameter.

And thanks for the script, should be faster than the current way I do it.

Regards,

Edit:

$commandTCP = {
    param($1,$2);
    try {
        $null = New-Object System.Net.Sockets.TCPClient -ArgumentList $1,$2;
        $true;
    } catch {
        $false;
    }
} 

is faster than:

$commandTCP = {
    param($1,$2);
    test-netconnection -computername $1 -port $2 -informationlevel quiet;
} 

at least for me

Sweet and thanks again

  • Edited by O.Ragain 11 hours 14 minutes ago
Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 3:43pm

Thanks, thanks for confirming I did not mis read that TechNet doc. Might have been a hidden parameter :) It would be nice if they made it a parameter.

And thanks for the script, should be faster than the current way I do it.

Regards,

Edit:

$commandTCP = {
    param($1,$2);
    try {
        $null = New-Object System.Net.Sockets.TCPClient -ArgumentList $1,$2;
        $true;
    } catch {
        $false;
    }
} 

is faster than:

$commandTCP = {
    param($1,$2);
    test-netconnection -computername $1 -port $2 -informationlevel quiet;
} 

at least for me

Sweet and thanks again

  • Edited by O.Ragain Thursday, September 03, 2015 7:48 PM
September 3rd, 2015 7:35pm

Thanks, thanks for confirming I did not mis read that TechNet doc. Might have been a hidden parameter :) It would be nice if they made it a parameter.

And thanks for the script, should be faster than the current way I do it.

Regards,

Edit:

$commandTCP = {
    param($1,$2);
    try {
        $null = New-Object System.Net.Sockets.TCPClient -ArgumentList $1,$2;
        $true;
    } catch {
        $false;
    }
} 

is faster than:

$commandTCP = {
    param($1,$2);
    test-netconnection -computername $1 -port $2 -informationlevel quiet;
} 

at least for me

Sweet and thanks again

  • Edited by O.Ragain Thursday, September 03, 2015 7:48 PM
Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 7:35pm

Cheers, you're very welcome. Glad I could help out.
September 3rd, 2015 10:09pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics