## 基本構文
```
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) ### インスタンスのネットワーク設定 ``` ...
-
--- ## 地理構成・リージョン設計 | AWS | Azure | 説明 | |-----|-------|------| | - | ジオ | Azure独自の地理的分類単位 | | リージョン | リージョン | データセンター群の配置単位 | | - | リージョ...
-
# サインイン画面 [TrendAI Vision One™ サインイン](https://signin.v1.trendmicro.com/) # サブスクリプションの種類 - 従量課金(PAYG) [TrendAI Vision One™ (PAYG)](https://...
-
HTTPS設定 顧客・ベンダー作業シーケンス図 ALBとEC2のHTTPS設定における顧客とベンダーの作業フローを時系列で示したシーケンス図 ベンダ...
-
# インストール [https://www.vim.org/download.php](https://www.vim.org/download.php) # カスタマイズ 1. Vimの設定ファイル(_vimrc)を作成 **ファイルパス**: C:\Users\(ユーザ...
0 件のコメント:
コメントを投稿