Scripting.FileSystemObject
(1)
Wscript.CreateObject
(1)
IpList.AtEndOfStream
(1)
Wscript.Shell
(1)
Database
(1)
IpList.readLine
(1)
Windows
(1)
IpList
(1)
Script to Import Reservations in DHCP Works on Server 2003 but not on Server 2008
Asked By Greg H
20-Nov-09 03:57 PM
We need to import hundreds of DHCP reservations into our DHCP server
with the IP, name, type, MAC address. We have a script that worked
with 2003, importing the IP and MAC address but it does not work with
Windows 2008.
Below is our script. Does anyone have one that works with 2008 or can
help us modify our existing script?
Thanks.
----
Set fso = Wscript.CreateObject
("Scripting.FileSystemObject")
Set shell = Wscript.CreateObject("Wscript.Shell")
Set ipList=fso.OpenTextFile("c:\ListFile.txt", 1, false)
Do While not ipList.AtEndOfStream
rLine=Trim(ipList.readLine)
MAC = Right(rLine, Len(rLine) - InStrRev(rLine, ","))
IP = Left(rLine, InStrRev(rLine, ",") - 1)
If not IP = "" or MAC = "" then
shell.run "netsh dhcp server scope 10.10.0.0 add
reservedip " & IP & " " & MAC, 0, True
End If
Loop
----------------
You should be able to simply export the DHCP database and import itinto the
RemyMaza replied to Greg H
22-Nov-09 03:32 PM
You should be able to simply export the DHCP database and import it
into the 2008 server. Check the links below for help:
http://technet.microsoft.com/en-us/library/cc776587(WS.10).aspx
http://blogs.technet.com/networking/archive/2008/06/27/steps-to-move-a-dhcp=
-database-from-a-windows-server-2003-or-2008-to-another-windows-server-2008=
-machine.aspx
Cheers,
Matt
To debug this issue you need to run a command like the one below from
Pegasus [MVP] replied to Greg H
21-Nov-09 02:56 PM
To debug this issue you need to run a command like the one below from the
Command Console, then see what happens:
netsh dhcp server scope 10.10.0.0 add reservedip 10.10.0.55
02-06-1B-DE-FD-FC
Thanks for the response. That scenario does not apply in oursituation.
Greg H replied to RemyMaza
23-Nov-09 01:28 PM
Thanks for the response. That scenario does not apply in our
situation. We do not have a database to import. We are moving from
statically assigned IPs to DHCP (yeah, I know, its 2009 and we are
using static IPs. Pretty funny. it is due to Security issues.)
We have a spreadsheet of hundreds of IP addresses of computers that
currently have static IP addresses. When we switch to DHCP, these
computers must have DHCP reservations so they have the same IP
addresses everyday instead of random addresses that DHCP normally
gives out. it is required for security purposes that the IPs not
change on these computers--the security details are too long to get
into.
Thanks,
Greg
n
canIf the script works for 2003 then run the script on a 2003 DHCP serverthen
RemyMaza replied to Greg H
28-Nov-09 10:37 PM
can
If the script works for 2003 then run the script on a 2003 DHCP server
then export the database and import it into a 2008 server. That
should work. it is a few extra steps but it should suffice.
Cheers,
Matt
can help us modify our existing script? Thanks. - -- - Set fso = Wscript.CreateObject ("Scripting.FileSystemObject") Set shell = Wscript.CreateObject("Wscript.Shell") Set ipList = fso.OpenTextFile("c: \ ListFile.txt", 1, false) Do While not ipList.AtEndOfStream rLine = Trim(ipList.readLine) MAC = Right(rLine, Len(rLine) - InStrRev
can help us modify our existing script? Thanks. - -- - Set fso = Wscript.CreateObject ("Scripting.FileSystemObject") Set shell = Wscript.CreateObject("Wscript.Shell") Set ipList = fso.OpenTextFile("c: \ ListFile.txt", 1, false) Do While not ipList.AtEndOfStream rLine = Trim(ipList.readLine) MAC = Right(rLine, Len(rLine) - InStrRev
run / launch a bat file using that information. Ive tried wscript.run and wsshell.run, but they dont seem to work. Any suggestions? Set oNet = Wscript.CreateObject("Wscript.Network") Set ADSysInfo CreateObject("ADSystemInfo") Set objUser = GetObject("LDAP: / / " & ADSysInfo.UserName &"") Set WshShell = CreateObject("Scripting.FileSystemObject") Wscript.echo "Script Path: \ domain.loc \ netlogon \ ou \ "& objUser.ScriptPath 'wscript.run " \ domain.loc \ netlogon \ ou \ "& objUser.ScriptPath 'wshshell.run " \ domain
Group Policy on each one of our servers: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso, d, dc, i, Command i = 0 Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.Drives For Each d in dc i Group Policy on each one of our servers: Set WshShell = WScript.CreateOb
Group Policy on each one of our servers: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso, d, dc, i, Command i = 0 Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.Drives For Each d in dc i Group Policy on each one of our servers: Set WshShell = WScript.CreateOb
Group Policy on each one of our servers: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso, d, dc, i, Command i = 0 Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.Drives For Each d in dc i Group Policy on each one of our servers: Set WshShell = WScript.CreateOb
Group Policy on each one of our servers: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso, d, dc, i, Command i = 0 Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.Drives For Each d in dc i Group Policy on each one of our servers: Set WshShell = WScript.CreateOb
Group Policy on each one of our servers: Set WshShell = WScript.CreateObject("WScript.Shell") Dim fso, d, dc, i, Command i = 0 Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.Drives For Each d in dc i Group Policy on each one of our servers: Set WshShell = WScript.CreateOb