banner



Which Of The Following Authentication Services Uses A Default Tcp Of 389?

Test-NetConnection – a ready-to-use cmdlet to bank check network connection has appeared in PowerShell 4.0 (Windows 2012 R2, Windows eight.1 and newer). You can employ this cmdlet to check the response and availability of a remote server or network service on it, TCP ports blocked past firewalls, cheque ICMP availability and routing. In fact, the Examination-NetConnection cmdlet tin supercede several standard network admin tools at once: ping, traceroute, TCP port scanner, etc.

Contents:

  • Testing for Open/Closed Server TCP Ports with Test-NetConnection
  • Test-NetConnection in PowerShell Monitoring Scripts
  • Simple IP Network / Port Scanner with PowerShell

From fourth dimension to time, any administrator has to check service availability on a remote server past checking remote TCP port response (for example, the availability of an email or spider web server). Moreover, most admins are used to perform such a port check with the telnet command. For example, to brand sure the SMTP service  responds on the email server (past default, information technology responds on TCP Port 25) it is plenty to run telnet ny-msg01.woshub.com 25 command. Merely starting from Windows seven, the telnet client has become a characteristic to be installed separately. Let's see how to check for open/airtight TCP ports using PowerShell.

The primary benefit of the Examination-NetConnection cmdlet is that it is already a part of all modern versions of Windows and you don't need to install information technology separately. The cmdlet is a part of the NetTCPIP module (starting with PoSh v4.0).

Tip. Yous tin check the current installed version of PowerShell with the control: $PSVersionTable.PSVersion

$PSVersionTable.PSVersion

Value 4 in the Major cavalcade ways that PowerShell 4.0 is installed on your computer.

Testing for Open/Closed Server TCP Ports with Test-NetConnection

Let's check if TCP Port 25 (SMTP protocol) is open (available) on the remote email server using Test-NetConnection:

Test-NetConnection -ComputerName ny-msg01 -Port 25

Note. Using Exam-NetConnection cmdlet, you can bank check only TCP port connection, and it is not applicative to check the availability of the remote UDP ports.

The shortened version of the aforementioned control looks similar this: TNC ny-msg01 -Port 25

Test-NetConnection check remote tcp port

Let's consider the event of the control:

ComputerName           : ny-msg01 RemoteAddress          : ten.20.1.7 RemotePort             : 25 InterfaceAlias         : CORP SourceAddress          : 10.twenty.1.79 PingSucceeded          : True PingReplyDetails (RTT) : 0 ms TcpTestSucceeded       : Truthful        

As you lot tin run across, the cmdlet resolves the server proper name to IP address, checks the ICMP response (similar to ping) and the availability of the TCP port. The specified server responds via ICMP (PingSucceeded = True) and the TCP Port 25 is open (RemotePort=25, TcpTestSucceeded= True).

Note. In some cases, information technology may occur that PingSucceeded=Imitation, and TcpTestSucceeded=True. It is likely to mean that ICMP Ping is forbidden on the remote server.

The cmdlet has a special parameter –CommonTCPPort, which allows yous to specify the name of a known network protocol (HTTP, RDP, SMB, WINRM).

For case, to check the availability of an HTTP web server, you tin apply the command:

Test-NetConnection -ComputerName woshub.com -CommonTCPPort HTTP

Or RDP port (3389) availability:

Exam-NetConnection ny-rds1 –CommonTCPPort RDP

You can list all the parameters that the Test-NetConnection cmdlet returns:

Exam-NetConnection ny-man01 -port 445|Format-List *

Test-NetConnection all connection state properties

If yous simply demand to see if the port is available, it can be checked more quickly:

TNC ny-msg1 -Port 25 -InformationLevel Tranquillity

The cmdlet returned True, which means the remote port is accessible.

TNC ny-msg1 -Port 25 -InformationLevel Quiet

Tip . In earlier PowerShell versions, you could check TCP port availability every bit follows:

(New-Object System.Internet.Sockets.TcpClient).Connect('ny-msg01', 25)

(New-Object System.Net.Sockets.TcpClient).Connect

In Windows 10 / Windows Server 2016, you lot tin use the Exam-NetConnection cmdlet to trace the route to a remote server using the –TraceRoute parameter (coordinating to tracert command in Windows). Using the –Hops parameter, you tin can limit the maximum number of hopes during route check.

Exam-NetConnection ny-man01 –TraceRoute

The cmdlet returned the network summary filibuster when accessing the server in milliseconds (PingReplyDetails (RTT): 41 ms) and all the IP addresses of the routers on the manner to the target server.

Test-NetConnection: powershell TraceRoute

Test-NetConnection in PowerShell Monitoring Scripts

The following command allows you to check the availability of a specific port on a number of servers, the list of which is stored in a patently text file list_servers.txt. We need the servers where the specified service doesn't respond:

Get-Content c:\PS\list_servers.txt |  where { -NOT (Test-Netconnection $_ -Port 25  -InformationLevel Quiet)}| Format-Table -AutoSize

Similarly, yous tin create a simple monitoring script that checks the availability of servers and displays a notification if one of the servers is unavailable.

For case, you can check the availability of basic services on all domain controllers (a DC listing can be obtained with the Get-ADDomainController cmdlet). Let'south check the following services on DC (the PortQry tool has a like "Domain and trusts" rule):

  • RPC – TCP/135
  • LDAP – TCP/389
  • LDAP – TCP/3268
  • DNS – TCP/53
  • Kerberos – TCP/88
  • SMB – TCP/445

$Ports  = "135","389","636","3268","53","88","445","3269", "80", "443"
$AllDCs = Become-ADDomainController -Filter * | Select-Object Hostname,Ipv4address,isGlobalCatalog,Site,Forest,OperatingSystem
ForEach($DC in $AllDCs)
{
Foreach ($P in $Ports){
$check=Test-NetConnection $DC -Port $P -WarningAction SilentlyContinue
If ($check.tcpTestSucceeded -eq $true)
{Write-Host $DC.name $P -ForegroundColor Green -Separator " => "}
else
{Write-Host $DC.name $P -Separator " => " -ForegroundColor Red}
}

The script will check the specified TCP ports on the domain controllers, and if one of the ports is unavailable, information technology volition highlight it in red (y'all tin run this PowerShell script equally a Windows service).

poweshell: test for open and closed ports on an active directory domain controller

Elementary IP Network / Port Scanner with PowerShell

You tin can as well implement a simple port and IP subnet network scanner to scan remote servers or subnets for open/closed TCP ports.

Scan the range of IP addresses on open up port 3389:

foreach ($ip in 100..150) {Test-NetConnection -Port 3389 -InformationLevel "Detailed" 192.168.ane.$ip}

Scan the range of TCP ports from 1 to 1024 on the specified remote server:

foreach ($port in 1..1024) {If (($a=Test-NetConnection srvfs01 -Port $port -WarningAction SilentlyContinue).tcpTestSucceeded -eq $true){ "TCP port $port is open!"}}

powershell network port scanner script

Source: http://woshub.com/checking-tcp-port-response-using-powershell/

Posted by: fishervered1989.blogspot.com

0 Response to "Which Of The Following Authentication Services Uses A Default Tcp Of 389?"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel