Setup DHCP Server using NETSH


I need to setup DHCP Servers automaticelly.
As I found no useful documentation for the API I decide to do with netsh.
This is the script I wrote for:
Dhcp Server add Scope "HH-TPC Netz" set state 0
Dhcp Server Scope add iprange
Dhcp Server Scope set optionvalue 03 IPADDRESS ""
Dhcp Server Scope set optionvalue 06 IPADDRESS "" ""
Dhcp Server Scope set optionvalue 44 IPADDRESS ""
Dhcp Server Scope set optionvalue 51 DWORD "86400"
Dhcp Server Scope add optiondef 161 "FTP Server" IPADDRESS ""
Dhcp Server Scope add optiondef 162 "FTP-Pfad" STRING "Wyse"

It works without the last three lines.
The lease time (option 51) is not set right and the last both lines return an error:
DHCP Server Add OptionDef failed.
Parameter(s) passed are either incomplete or invalid.

What the Add Optiondefs should do is shown in the pictures.
Have anybody an idea how to make it working with Windows Server 2003 ?


Who is Participating?
kuknoConnect With a Mentor Commented:

use the netsh dump or export command to export the DHCP server config AFTER you have added the optiondef with the GUI. The dump/export will contain the correct netsh commands to recreate the configuration, including the "add optiondef".

Apparently you speak german, so I post the link to the german article in technet:

andre72Author Commented:
sorry for delay - I'd to wait for responce of my customer ... It works great, thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.