Setup DHCP Server using NETSH

Posted on 2008-11-04
Last Modified: 2012-05-05

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 ?


Question by:andre72
    LVL 10

    Accepted Solution


    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:


    Author Closing Comment

    sorry for delay - I'd to wait for responce of my customer ... It works great, thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
    A quick step-by-step overview of installing and configuring Carbonite Server Backup.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video discusses moving either the default database or any database to a new volume.

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now