Networking

Test-NetworkPort

Overview

Allows testing if a TCP port is reachable on the target network host.

Cmdlet Attributes

Copy
Copied
CmdletBinding : []
Alias         : ['nc']

Parameters

Target

The target endpoint of the port scan. This parameter value should either be a [ System.Net.IPAddress ] value, or a string representation of an IP address ( ex: '192.168.255.1' ).

Attributes

Copy
Copied
Parameter      : [Mandatory = $true, ValueFromPipeline = $true]
Alias          : ['t']
ValidateScript : [{ $_ -is [ IPAddress ] -or [ IPAddress ]::TryParse( $_, [ Ref ] $null ) }]

Ports

A [ System.Array ] of [ System.Int32 ] indicating TCP ports that should be scanned.

Attributes

Copy
Copied
Parameter      : [Mandatory = $true]
Alias          : ['p']
ValidateScript : [{ $_ -is [ Int32 ] -or $_ -is [ Int32[ ] ] }]

Timeout : System.Int32

How long the port assessment should wait, in milliseconds, before considering the port closed.

Default: 250

Attributes

Copy
Copied
Parameter : []
Alias     : ['w']

Example

Copy
Copied
PS> Test-NetworkPort -Target '192.168.255.5' -Ports 80, 443 
Target         80      443 
------         --      --- 
192.168.255.5  True    True 

History

Author Date Version Release Notes
Anthony Maxwell 10/18/2023 1.0.0 - Initial Release.