Network Scanner PowerShell Script Documentation

Synopsis

This PowerShell script performs network scanning on specified CIDR ranges, offering various customization options and output formats.

Description

The script conducts network scans based on provided CIDR notations. It supports multiple CIDR inputs, customizable ping settings, port scanning, DNS resolution, and various output options. The script is designed for network administrators and security professionals to efficiently scan and analyze network environments.

Parameters

Parameter Description Required Default
CIDR CIDR notation(s) to scan. Can be a single CIDR or an array. Yes N/A
PingCount Number of ping attempts per host. No 1
Timeout Timeout in milliseconds for each ping attempt. No 1000
ShowAll If set, shows results for all hosts, not just alive ones. No False
ExportCSV Path to export results as CSV. No N/A
HostThrottleLimit Maximum number of concurrent host scans. No 100
PortThrottleLimit Maximum number of concurrent port scans per host. No 50
ResolveDNS Attempts to resolve DNS names for alive hosts. No False
Ports Array of specific ports to scan. No N/A
TopPorts Scan top N most common ports. Values: 10, 20, 30, 40, 50. No N/A
LogFile Path to the log file. No .\scan_log.txt
OutputFormat Output format for results. Values: "CSV", "JSON", "XML". No "CSV"
Exclude Array of IP addresses or subnets to exclude from scan. No N/A
UseTcpSyn Uses TCP SYN packets for host discovery. No False
NetworkInterface Network interface to use for the scan. No N/A

Usage Examples

1. Basic scan of a single CIDR range:

.\scanner.ps1 -CIDR "192.168.1.0/24"

Performs a basic scan on the specified CIDR range.

2. Scan multiple CIDR ranges:

.\scanner.ps1 -CIDR "192.168.1.0/24","10.0.0.0/16"

Scans multiple CIDR ranges in a single execution.

3. Customize ping settings:

.\scanner.ps1 -CIDR "192.168.1.0/24" -PingCount 3 -Timeout 500

Adjusts the number of ping attempts and timeout for each host.

4. Show all hosts (including non-responsive ones):

.\scanner.ps1 -CIDR "192.168.1.0/24" -ShowAll

Displays results for all hosts, not just the responsive ones.

5. Export results to CSV:

.\scanner.ps1 -CIDR "192.168.1.0/24" -ExportCSV "C:\results.csv"

Saves the scan results to a CSV file at the specified path.

6. Adjust concurrency limits:

.\scanner.ps1 -CIDR "192.168.1.0/24" -HostThrottleLimit 50 -PortThrottleLimit 25

Sets custom limits for concurrent host and port scanning operations.

7. Resolve DNS names:

.\scanner.ps1 -CIDR "192.168.1.0/24" -ResolveDNS

Attempts to resolve DNS names for responsive hosts.

8. Scan specific ports:

.\scanner.ps1 -CIDR "192.168.1.0/24" -Ports 80,443,3389

Scans the specified ports on responsive hosts.

9. Scan top N most common ports:

.\scanner.ps1 -CIDR "192.168.1.0/24" -TopPorts 20

Scans the top 20 most common ports on responsive hosts.

10. Use a custom log file:

.\scanner.ps1 -CIDR "192.168.1.0/24" -LogFile "C:\custom_scan_log.txt"

Specifies a custom path for the scan log file.

11. Change output format:

.\scanner.ps1 -CIDR "192.168.1.0/24" -OutputFormat "JSON"

Changes the output format of the results to JSON.

12. Exclude specific IP addresses or subnets:

.\scanner.ps1 -CIDR "192.168.1.0/24" -Exclude "192.168.1.100","192.168.1.200/30"

Excludes specified IP addresses or subnets from the scan.

13. Use TCP SYN packets for host discovery:

.\scanner.ps1 -CIDR "192.168.1.0/24" -UseTcpSyn

Uses TCP SYN packets instead of ICMP for host discovery.

14. Specify a network interface:

.\scanner.ps1 -CIDR "192.168.1.0/24" -NetworkInterface "Ethernet"

Uses the specified network interface for scanning.

15. Comprehensive scan with multiple options:

.\scanner.ps1 -CIDR "192.168.1.0/24","10.0.0.0/16" -PingCount 2 -Timeout 1000 -ShowAll -ExportCSV "C:\results.csv" -ResolveDNS -TopPorts 50 -LogFile "C:\scan_log.txt" -OutputFormat "JSON" -UseTcpSyn -NetworkInterface "Wi-Fi"

Performs a detailed scan with multiple CIDR ranges, custom ping settings, DNS resolution, port scanning, custom output, and more.

Script Details