Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

creating a list of IP adresses of a subnet to a textfile ...i just seem to mess up something and cant see what

$
0
0

the goal is to get asked for an ip range eg. 192.168.20.x of any given Class C subnet

and then have a start and end ip for the range (which should at the end reflect our DHCP range)

the result should create a .txt with all the IPs that it will have to scan later on for clients and some WMI stuff

part 1 seems pretty simple :

$oct1=Read-host "Octet 1"
$oct2=Read-host "Octet 2"
$oct3=Read-host "Octet 3""

asks for 192.168.0 ... so far - so good

part 2 then goes somehow like this:

$start=Read-host "start"
$end=Read-host "end"

but here i fail:

"$oct1.$oct2.$oct3.$start" gives me 192.168.0.100

"$oct1.$oct2.$oct3.$end" gives me 192.168.0.150

$start..$end gives me the list i basically wanted like

100
101
102
...

How do i combine this to get  this result:
192.168.0.100
192.168.0.101
192.168.0.102
...

i am failing for hours now ... it cant be much

cheers and thx

Alex


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>