Microsoft Windows DHCP Team Blog

The world's most deployed DHCP Server! Deploy and discuss about your fav. server, here!

Creating reservation for active leases.

Creating reservation for active leases.

  • Comments 3
  • Likes

Note: In Windows Server 2008 R2, active leases can be converted to reservations by just doing a right click in the DHCP Server management console. :)


If anyone is interested…or needs this in the future:



1. Dump all leases:

Netsh dhcp server scope show client


2. import the output (after cutting the first descriptional lines) to an excel file as space delimited file, remove unnecessary infos (i.e. “-” from the MACs and the unnecessary columns), then export to a file so that only the following info is retained in the file:




3. add reservation for all clients: create a script which processes the lines  of the output file and executes:

Netsh dhcp server scope add reservedip IP MAC

(here the IP and the MAC should come from the outputfile)



Script to read from file and create reservation (without error checking):




Const TEST_FILE_PATH = "C:\ip-mac.txt"

Dim objFileSystemObject

Dim objOurExistingFileStream

Dim strLine

Dim oShell

Dim myComm

Set objFileSystemObject = CreateObject("Scripting.FileSystemObject")


'Open our file

Set objOurExistingFileStream = objFileSystemObject.OpenTextFile(TEST_FILE_PATH)


Set oShell = WScript.CreateObject ("")


'Read out the file-content

Do Until objOurExistingFileStream.AtEndOfStream


'each line contains an Ip and a MAC

strLine = objOurExistingFileStream.ReadLine

'Wscript.Echo strLine

      myComm = "%COMSPEC% /c Netsh dhcp server scope add reservedip " + strLine +" >>c:\DhcpReservation.log"

strLine myComm,,True



'Close it


Set objOurExistingFileStream = Nothing

Set objFileSystemObject = Nothing

Set oShell = Nothing


and finally logs will be available at c:\DhcpReservation.log for verification & validation.

NOTE: Thanks to Mr.Balint who has shared the Script with US.

-RamaSubbu SK

  • thanks, I had a type mismatch vbs error on the final strLine entry. I added 'on error resume next' at the beginning and all worked OK.

    If you wanted to put a reservation name and description in as well, how do you do this?

    thanks :-)

  • Wish List Item:  It would be great if you could just right click on an active lease in the management tool and select "Convert to reservation"!

  • Hey Scott,

    Your wish has been granted :) . You can convert active leases to reservations easily by doing a right click in Windows Server 2008 R2 Beta DHCP Server.


    Raunak Pandya

    DHCP Server Team

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment