This is the script that I used to add our new wireless access points. It's a cmd file which relies on two external text files for input - they should be saved in the same folder as the cmd file. The first (servers.txt) lists the IP addresses of your DHCP servers, because you'll want to make the reservations on all of them; we have two. The second (wapmacs.txt) lists the details of the objects for which you want to make a reservation. It will need to contain as tab separated values the IP address you want to reserve for the object, the MAC address of the object, the name of the object and (optionally) a description for the object.
Code:
@echo off
FOR /F %%b IN (%~dp0servers.txt) DO @call :perserver %%b
goto :EOF
:perserver
FOR /F "delims=," %%c IN (%~dp0WAPMACs.txt) DO call :listit %1 %%c
goto :EOF
:listit
echo %*
pause
echo %1 + %2 + %3 + %4
::netsh dhcp server %1 scope xx.xx.xxx.0 add reservedip %2 %3 %4
echo netsh dhcp server %1 scope xx.xx.xxx.0 add reservedip %2 %3 %4
pause
goto :EOF
NOTE: as it stands, this code will simply echo the parameters it finds and the netsh command it creates; it won't do anything, it's in test mode. To use it in anger you'll need to uncomment the netsh line and comment the echoes and pauses below :listit. Use it at your own risk - I won't be responsible for consequences.
Examples of the content of the accompanying files:
Code:
WAPMACS.txt
xxx.xxx.xxx.105 00156CD656B0 WirelessAP29 "Wireless Access Point"
xxx.xxx.xxx.106 00156CD656B1 WirelessAP30 "Wireless Access Point"
xxx.xxx.xxx.107 00156CD656B2 WirelessAP31 "Wireless Access Point"
Code:
servers.txt
xx.xx.xxx.14
xx.xx.xxx.15