Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Today's Posts

Windows

Windows forum sponsored by

For all of your Windows problems

Go Back   EduGeek.net Forums > Technical > Windows
Reply
 
LinkBack Thread Tools Search Thread
Sponsored Links
Old 15-11-2007, 12:06 PM   #1
 
Gonk's Avatar
 
Join Date: Aug 2007
Location: Pembrokeshire
Posts: 85
uk uk pembrokeshire
Thanks: 12
Thanked 2 Times in 2 Posts
Rep Power: 4 Gonk is on a distinguished road
Send a message via MSN to Gonk
Default Is there a way of creatin DHCP reservations from a CSV file?

Does anyone know of a way that I can create all of my DHCP reservations from a CSV file? :?

It would really help as I'm trying to put this network in order and get some order.

Thanks in advance

Gonk
  Reply With Quote
Old 15-11-2007, 01:26 PM   #2
 
Iain's Avatar
 
Join Date: Oct 2006
Location: Warwickshire
Posts: 98
uk
Thanks: 3
Thanked 29 Times in 15 Posts
Rep Power: 10 Iain will become famous soon enoughIain will become famous soon enough
Default Re: Is there a way of creatin DHCP reservations from a CSV f

I don't think you can do this from the GUI, but you should be able to with a bit of scripting. e.g. using vbscript and the NETSH command:

Code:
' script to bulk create DHCP reservations from a .csv file

' Set a couple of constants
' Set following line to IP address of DHCP server, or leave blank for local computer
Const DHCPServer = "" 
' Set following line to address scope where reservation is to be added
Const SCOPE = "192.168.1.0" 
' Set following line to location of .csv file containing the reservation to be added
Const FileLocation = "C:\reservations.csv" 

' read in the csv file
' format:
' <Reserved IP>,<MAC>,<Client Name>,<Description>

Const forReading = 1

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCSVFile = objFSO.OpenTextFile(FileLocation,forReading)

' Process csv file
Do While objCSVFile.AtEndOfStream <> True
	' read in a line from the csv file
	strLine = objCSVFile.ReadLine

	' seperate the cells on the line
	arrCells = split(strLine,",",-1,1)

	' get the values from the cells
	strIP = arrCells(0)
	strMAC = arrCells(1)
	strClientName = arrCells(2)
	strDescription = arrCells(3)

	' build the NETSH command string
	strCmd = "netsh dhcp server " & DHCPServer & " scope " & SCOPE & " add reservedip " & _
              strIP & " " & strMAC & " " & strClientName & " """ & strDescription & """"

	' run the NETSH command
	objShell.Run strCmd, 1, TRUE
Loop

' All done so close the csv file
objCSVFile.close

' Clean up objects
Set objCSVFile = Nothing
Set objFSO = Nothing
Set objShell = Nothing

WScript.Echo "All done."
I have not fully tested this, so as always make a backup before using it.

Hope that is of some help,

Iain.
  Reply With Quote
Old 15-11-2007, 01:38 PM   #3
 
Heebeejeebee's Avatar
 
Join Date: Nov 2006
Location: Intergalactic Cruise
Posts: 687
uk
Thanks: 17
Thanked 27 Times in 23 Posts
Rep Power: 11 Heebeejeebee has a spectacular aura aboutHeebeejeebee has a spectacular aura about
Default Re: Is there a way of creatin DHCP reservations from a CSV file?

Use...

netsh dhcp server \\servername dump >c:\dhcp.txt

... to get your current list. Look for the reservation section:

Code:
    
   # ======================================================================
   #  Start Add ReservedIp to the Scope : IP of Server Server : IP of Server            
   # ======================================================================


Dhcp Server SERVER-IP Scope SCOPE-IP Add reservedip RESERVEVED-IP MAC-ADDRESS "SomePC" "Description" "BOTH"
and paste in your own list (from your spreadsheet).

then import the amended file with

netsh exec c:\dhcp.txt

Works a treat for us.

HBJB
  Reply With Quote
The Following User Says Thank You to Heebeejeebee For This Useful Post:
Gonk (06-02-2009)
Old 16-11-2007, 11:35 AM   #4
 
Gonk's Avatar
 
Join Date: Aug 2007
Location: Pembrokeshire
Posts: 85
uk uk pembrokeshire
Thanks: 12
Thanked 2 Times in 2 Posts
Rep Power: 4 Gonk is on a distinguished road
Send a message via MSN to Gonk
Default Re: Is there a way of creatin DHCP reservations from a CSV f

@Heebeejeebee & Iain

Gents,

Thanks for your help, DHCP now a lot more organised!

Thanks for your help

Gonk
  Reply With Quote
Reply
Similar Threads
Thread Thread Starter Forum Replies Last Post
Access points not picking up DHCP reservations? Halfmad Networks 2 26-04-2007 02:11 PM
What to do for best with DHCP reservations? Kyle Windows 3 24-01-2007 11:11 PM
Script needed to check for file, rename and then copy a file tosca925 Scripts 4 23-03-2006 06:27 AM
VPN +DHCP Dos_Box Networks 7 30-09-2005 01:14 AM
DHCP kingswood Networks 10 07-09-2005 06:29 AM



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT +1. The time now is 05:07 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright EduGeek.net




website uptime

© 2005 - 2009 EduGeek.net