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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


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:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andre72Author Commented:
sorry for delay - I'd to wait for responce of my customer ... It works great, thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.