Reputation: 11
I am scanning some internal networks from a windows server currently a subnet at a time. I will be automating this at some stage but am not that familiar with powershell and am learning programming. Was after some guidance from the community.
The logic i have so far is
file = nmap_subnets.txt
scan = (nmap.exe -sV -T3 -O -F -version-light')
for subnet in file:
scan ('-oN $subnet.txt')
exit
nmap_subnets.txt will just contain one subnet per line ie 192.168.1.0/25 I then want for each subnet on a line use that subnet as the filename for the output from -oN
If the logic is wrong im open to any ideas.
Thanks
Upvotes: 1
Views: 895
Reputation: 7338
try this:
$file = ".\nmap_subnets.txt"
ForEach($range in get-content $file)
{
& nmap.exe -sV -T3 -O -F -version-light -oN $range
}
Upvotes: 1