## 基本構文
```
Test-NetConnection [-ComputerName] <string> [-Port <int>] [-InformationLevel <string>] [-TraceRoute]
```
## 使用例一覧
### 1. ホストへの接続確認(Ping相当)
```
Test-NetConnection www.google.com
```
- ホスト名の名前解決と ICMP 通信確認
- PingSucceeded が True なら疎通可能
### 2. TCPポートの疎通確認(例:443)
```
Test-NetConnection -ComputerName 192.168.1.10 -Port 443
```
- 指定IPの443番ポートにTCP接続できるか確認
- TcpTestSucceeded が True ならポートが開いている
### 3. ホスト名+ポート確認(DNS解決付き)
```
Test-NetConnection -ComputerName example.com -Port 80
```
- ホスト名をDNSで解決し、HTTPポート(80)への接続確認
### 4. トレースルート付きで確認
```
Test-NetConnection www.microsoft.com -TraceRoute
```
- 通信経路(ルーターのホップ)を表示
### 5. LAN内のIPに対して443ポート確認(スクリプト)
```
$subnet = "192.168.1"
1..254 | ForEach-Object {
$ip = "$subnet.$_"
$result = Test-NetConnection -ComputerName $ip -Port 443 -WarningAction SilentlyContinue
if ($result.TcpTestSucceeded) {
Write-Host "$ip is listening on port 443"
}
}
```
- サブネット内の全ホストに対して443ポートの疎通確認
- 成功したIPのみ表示
## 出力例
```
ComputerName : 192.168.1.10
RemoteAddress : 192.168.1.10
RemotePort : 443
InterfaceAlias : Ethernet
TcpTestSucceeded : True
```
2025/11/12
PowerShellコマンド:Test-NetConnection 使用例
登録:
コメントの投稿 (Atom)
人気の投稿
-
## 作業前確認 [Amazon Linux 2023 リリースノート](https://docs.aws.amazon.com/ja_jp/linux/al2023/release-notes/relnotes.html) ### インスタンスのネットワーク設定 ``` ...
-
## 基本構文 ``` Test-NetConnection [-ComputerName] <string> [-Port <int>] [-InformationLevel <string>] [-TraceRoute] ``` ## ...
-
Gitでは変更の保存先が4つの場所に分かれており、コマンドによってどの場所まで変更を反映するかが決まる。 `add` → `commit` → `push` と段階を踏むのが基本で、`commit -a` や `pull` は複数の操作をひとつのコマンドにまとめた省略形にあ...
-
[AWS CloudFormation とは何ですか?](https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/Welcome.html) ## CloudFormationの動作概要 ポイン...
-
SCTとDMSを使用してオンプレミスにあるOracleをAWSのRDSへ移行してみる。 - [AWS Schema Conversion Toolとは](https://docs.aws.amazon.com/ja_jp/SchemaConversionTool/latest/...
0 件のコメント:
コメントを投稿