VBScript DHCP Scope Information

The following VBScript allows you to extract information from DHCP tables.

You will need to download and register DHCPOBJS.DLL before using this code.

set dhcpmanager=CreateObject("Dhcp.Manager")  'Create objects for use
set dhcpserver=dhcpmanager.servers.Connect(strServer1)
set dhcpscopeNew=dhcpserver.Scopes.CreateNew

dhcpscopeNew.StartAddress=strIpRangeBegin 'Create new scope
dhcpscopeNew.EndAddress=strIpRangeEnd
dhcpscopeNew.Mask=strdhcpSubNet
dhcpscopeNew.Name=strdhcpname
dhcpscopeNew.Active=True
dhcpscopeNew.Update

dhcpserver.Scopes(strdhcpIP).Exclusions.CreateNew() 'Create 1st exclusion
dhcpserver.StartAddress=strIpRangeBegin
dhcpserver.EndAddress=strExRangeEnd31
dhcpserver.Update

dhcpserver.Scopes(strdhcpIP).Exclusions.CreateNew() 'Create 2nd exclusion
dhcpserver.StartAddress=strExRangeBegin144
dhcpserver.EndAddress=strIpRangeEnd
dhcpserver.Update

dhcpserver.Scopes(strdhcpIP).Options.Add 3, strIPRouter 'Configure scope
dhcpserver.Scopes(strdhcpIP).Options.Add 6, Array(strdhcpDNS1, strdhcpDNS1)
dhcpserver.Scopes(strdhcpIP).Options.Add 15, strDnsPath
dhcpserver.Scopes(strdhcpIP).Options.Add 51, 259200
dhcpserver.Update

dhcpserver.Disconnect