You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Script to parallel check TCP ports, Ping tests, and DNS resolution based on a CSV file containing the name, target, test type (TCP/Ping/DNS), and expected result
2
+
3
+
param (
4
+
[string]$CsvFilePath
5
+
)
6
+
7
+
# Check if the CSV file exists
8
+
if (-not (Test-Path$CsvFilePath)) {
9
+
Write-Host"CSV file not found: $CsvFilePath"-ForegroundColor Red
This PowerShell script is designed to perform parallel network tests based on a CSV configuration file. It allows network administrators to check the availability of TCP ports, perform ping tests, and resolve DNS names against specified servers. The results are color-coded for quick identification of successes and failures.
4
+
5
+
## Features
6
+
7
+
-**TCP Port Testing**: Checks if a TCP port is open on a specified target with a custom timeout.
8
+
-**Ping Testing**: Verifies if a target is reachable via ping.
9
+
-**DNS Resolution Testing**: Tests if a DNS server can resolve a specified hostname and displays the resolved IP address.
10
+
-**Parallel Execution**: Tests are run in parallel to optimize performance and reduce execution time.
11
+
-**CSV Configuration**: Tests are configured through a CSV file, making it easy to adjust and extend the test cases.
12
+
13
+
## Usage
14
+
15
+
### Script Parameters
16
+
17
+
-`-CsvFilePath`: Path to the CSV file containing the test configuration.
18
+
19
+
### CSV File Format
20
+
21
+
The CSV file should have the following columns:
22
+
23
+
-`Name`: A descriptive name for the test.
24
+
-`Target`: The target IP address or DNS server.
25
+
-`TestType`: The type of test to perform (`TCP`, `Ping`, or `DNS`).
26
+
-`ExpectedResult`: Expected result of the test (`1` for success, `0` for failure).
27
+
28
+
Example CSV file:
29
+
30
+
```csv
31
+
Cloudflare,1.1.1.1,Ping,1
32
+
Cloudflare,1.1.1.1,DNS,1
33
+
Google,1.1.1.1,Ping,1
34
+
Google,1.1.1.1,DNS,1
35
+
Google Website,google.com,443,1
36
+
YouTube Website,youtube.com,443,1
37
+
```
38
+
39
+
## Running the Script
40
+
41
+
Run the script in PowerShell by providing the path to the CSV file:
42
+
43
+
```powershell
44
+
.\PortCheck.ps1 -CsvFilePath .\example.csv
45
+
```
46
+
47
+
## Output
48
+
49
+
The script provides color-coded output indicating the success or failure of each test:
50
+
51
+
- Green: Test successful
52
+
- Red: Test failed
53
+
- Yellow: Unknown test type
54
+
55
+
Example output:
56
+
57
+
```
58
+
.\PortCheck.ps1 -CsvFilePath example.csv
59
+
60
+
Test successful: Cloudflare (1.1.1.1) is reachable with ping
61
+
Test successful: google.com resolved by DNS server 1.1.1.1 with IP 2a00:1450:401b:808::200e 142.251.143.78
62
+
Test successful: Google (1.1.1.1) is reachable with ping
63
+
Test successful: google.com resolved by DNS server 1.1.1.1 with IP 2a00:1450:401b:808::200e 216.58.208.206
64
+
Test successful: Google Website (google.com) on Port 443 is reachable
65
+
Test successful: YouTube Website (youtube.com) on Port 443 is reachable
66
+
```
67
+
68
+
## Contributing
69
+
70
+
If you have suggestions or improvements, feel free to submit a pull request or open an issue.
0 commit comments