Solved

Maintaning  Large DHCP Server and mac reservations

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is MicroStrategy.NET? 2 58
Independent domain networks for setup 6 109
windbg taking it's time 32 79
Task with PowerShell Script is failing with 0x41301 7 87
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…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
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…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now