Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Maintaning  Large DHCP Server and mac reservations

Posted on 2009-05-02
2
Medium Priority
?
487 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
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…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

916 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