Solved

Maintaning  Large DHCP Server and mac reservations

Posted on 2009-05-02
2
481 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hibernate on windows 10 18 139
What is MicroStrategy.NET? 2 66
how can I practice with windows server os 2 65
AD Replications issues 12 105
Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

786 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