Solved

Maintaning  Large DHCP Server and mac reservations

Posted on 2009-05-02
2
482 Views
Last Modified: 2012-06-27
Will be having new latops coming in an out and want to lock down the DHCP server scopes for only those laptops

Almost got it, but i have DHCP server with 70 + scopes
Made a txt file with IP,Mac Address
i can easily do

for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.1.0 add reservedip %i %j %k %l

And above works but then i have to do this for every scope everytime new laptop comes in
want to script this but it throws and error

would like to batch it

ie=
for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.1.0 add reservedip %i %j %k %l
for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.2.0 add reservedip %i %j %k %l
for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.1.3 add reservedip %i %j %k %l

when i create a batch file with that in there error msg i get is:

i was unexpected at this time.
D:\Apps\test>for /f "tokens=1-4 delims=," i k l

any ideas?

or a better way to do this?
0
Comment
Question by:crsol
2 Comments
 
LVL 15

Accepted Solution

by:
markpalinux earned 500 total points
ID: 24288445

Here is an example:

I was guessing it was ip addresses, if you are looking for four octets, then use 1-4.

Also the for loop you need to use two percent signs when in a cmd ( batch file) , at the command line you use one percent sign.  

for /f "tokens=1-4 delims=." %%i in (addresses.txt) do echo %%i %%j %%k %%l



Mark
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question