「PowerShell」特定TCP ポートが開いているか確認する

環境
Windows 10 home 64bit

書式
Test-NetConnection 対象IP -port 対象ポート

使用例1
特定 TCPポート80が開いているか確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\> Test-NetConnection localhost -port 80
ComputerName : localhost
RemoteAddress : ::1
RemotePort : 80
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : ::1
TcpTestSucceeded : True
PS C:\> Test-NetConnection localhost -port 80 ComputerName : localhost RemoteAddress : ::1 RemotePort : 80 InterfaceAlias : Loopback Pseudo-Interface 1 SourceAddress : ::1 TcpTestSucceeded : True
PS C:\> Test-NetConnection localhost -port 80                                                                                                                                                                                                   
ComputerName     : localhost
RemoteAddress    : ::1
RemotePort       : 80
InterfaceAlias   : Loopback Pseudo-Interface 1
SourceAddress    : ::1
TcpTestSucceeded : True

使用例2
特定 TCPポート8080が開いているか確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
PS C:\> Test-NetConnection localhost -port 8080
警告: TCP connect to (::1 : 8080) failed
警告: TCP connect to (127.0.0.1 : 8080) failed
ComputerName : localhost
RemoteAddress : ::1
RemotePort : 8080
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : ::1
PingSucceeded : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False
PS C:\> Test-NetConnection localhost -port 8080 警告: TCP connect to (::1 : 8080) failed 警告: TCP connect to (127.0.0.1 : 8080) failed ComputerName : localhost RemoteAddress : ::1 RemotePort : 8080 InterfaceAlias : Loopback Pseudo-Interface 1 SourceAddress : ::1 PingSucceeded : True PingReplyDetails (RTT) : 0 ms TcpTestSucceeded : False
PS C:\> Test-NetConnection localhost -port 8080
警告: TCP connect to (::1 : 8080) failed
警告: TCP connect to (127.0.0.1 : 8080) failed


ComputerName           : localhost
RemoteAddress          : ::1
RemotePort             : 8080
InterfaceAlias         : Loopback Pseudo-Interface 1
SourceAddress          : ::1
PingSucceeded          : True
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded       : False

 

PowerShell

Posted by arkgame