Hi

Does anyone know how to get a list of active leases from a
DHCp server using VBscript.

I have been looking about the web for ages, but the only
thing I have came across is DHCP Objects 1.0 from the
windows 2000 res kit, but there is little documentation on
how to extract the information that I want.

Can anyone Help???

Re: Get DHCP lease information by Yevgen

Yevgen
Mon Sep 13 17:32:37 CDT 2004

... you can use NETSH DHCP SERVER SCOPE (ZONE_IP) SHOW CLIENTS to output
current leases into a file and then parse values you need from a script ...


"Paul" <anonymous@discussions.microsoft.com> a écrit dans le message de
news:110301c4998b$26a778b0$a501280a@phx.gbl...
| Hi
|
| Does anyone know how to get a list of active leases from a
| DHCp server using VBscript.
|
| I have been looking about the web for ages, but the only
| thing I have came across is DHCP Objects 1.0 from the
| windows 2000 res kit, but there is little documentation on
| how to extract the information that I want.
|
| Can anyone Help???



RE: Get DHCP lease information by GBrumby

GBrumby
Wed Sep 15 22:23:01 CDT 2004

Paul,

I have taken my response verbatim (sorry) from another thread from a Paul
too !......

If you are asking about querying the DHCP server for information about
scopes, exclusions etc... then yes you can.

With Windows 2000 Server Resource Kit MS included the DHCPOBJS.DLL and .CHM
(Documentation) which will allow you to access the DHCP server information.
Not sure about a WINS equivalent (Microsoft perhaps may see this and tell us
.... PLEASE ?????) DHCPOBJS is a nice teaser, but leaves us Scripters high
and dry !!!!

THE BIG GROAN is that whilst you can get the Scopes, Reservations and
Exclusions, you CAN'T get access to the actual IP information for standard
leases ! MICROSOFT PLEASE HELP as I really need to get this info myself
mainly for MAC info to do WakeOnLan.

If ONLY the IP addresses, machine names and MACs could be accessed via this
I'd be happy happy happier !

If you have a programming person around, they could look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhcp/dhcp/dhcp_server_management_api.asp
which is the Programming API information about querying DHCP Server Service
for NT4, 2k and 2k3. A nice COM .OCX file would be appreciated ;-)

For Windows 2003 Server, MS improved the WMI infrastructure to support this
DHCP query (I believe WINS too). I don't have code to hand.

Yevgen is right in indicating NETSH DHCP ..... (Note this is useful for WINS
too !!!)
as this certainly works for Win2k environments, however is NOT an elegant
solution, albeit you can get the MAC for leases (note you don't get the
Machine Names though !!!), as you have to trap the results and parse the
output.... YUCK
but workable....

An example command line .....
netsh dhcp server scope 192.168.1.0 show clients
assuming the scope is 192.168.1.0 that is.....

Clearly you have to know the scope before you make the query so in a big
environment this may take some extra clever scripting, however that should
give you the jist of things..
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windowsserver2003/proddocs/datacenter/netsh_dhcp.asp

Hope this helps...
......

Further to this.....
NETSH on 2k and 2k3 Server only ! You can't seem to do the same query on XP
Pro , with even with 2k3 Admin tool kit installed ..... :-(
Mind you that may be something to do with XPSP2 or something not sure....

Regards
Greg

Re: Get DHCP lease information by Torgeir

Torgeir
Fri Sep 17 09:23:15 CDT 2004

Steve wrote:

> I have had need for this type of information also. What I did was to
> dump the information to a text file then parse the file as needed.
>
> dhcpcmd <server_ip> enumclients <scope> -v
> dhcpcmd 172.25.108.250 enumclients 172.25.100.0 -v >>C:\Working\dhcplease.txt
>
> the dhcpcmd is from one of the server resource kits, sorry i do
> remember whih one, but you can do site search for it at microsoft.
Hi

Dhcpcmd.exe is in the Windows NT 4.0 Service Pack 4 Support Tools.

How to Use the Dhcpcmd.exe Tool Included with Support Tools
http://support.microsoft.com/default.aspx?kbid=232213

Download link found here:

Windows NT Service Pack 4.0 Tools Not Included on CD-ROM
http://support.microsoft.com/default.aspx?kbid=206848


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

RE: Get DHCP lease information by Steve

Steve
Fri Sep 17 09:01:02 CDT 2004

I have had need for this type of information also. What I did was to dump
the information to a text file then parse the file as needed.

dhcpcmd <server_ip> enumclients <scope> -v
dhcpcmd 172.25.108.250 enumclients 172.25.100.0 -v >>C:\Working\dhcplease.txt

the dhcpcmd is from one of the server resource kits, sorry i do remember
whih one, but you can do site search for it at microsoft.

"GBrumby" wrote:

> Paul,
>
> I have taken my response verbatim (sorry) from another thread from a Paul
> too !......
>
> If you are asking about querying the DHCP server for information about
> scopes, exclusions etc... then yes you can.
>
> With Windows 2000 Server Resource Kit MS included the DHCPOBJS.DLL and .CHM
> (Documentation) which will allow you to access the DHCP server information.
> Not sure about a WINS equivalent (Microsoft perhaps may see this and tell us
> .... PLEASE ?????) DHCPOBJS is a nice teaser, but leaves us Scripters high
> and dry !!!!
>
> THE BIG GROAN is that whilst you can get the Scopes, Reservations and
> Exclusions, you CAN'T get access to the actual IP information for standard
> leases ! MICROSOFT PLEASE HELP as I really need to get this info myself
> mainly for MAC info to do WakeOnLan.
>
> If ONLY the IP addresses, machine names and MACs could be accessed via this
> I'd be happy happy happier !
>
> If you have a programming person around, they could look at
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhcp/dhcp/dhcp_server_management_api.asp
> which is the Programming API information about querying DHCP Server Service
> for NT4, 2k and 2k3. A nice COM .OCX file would be appreciated ;-)
>
> For Windows 2003 Server, MS improved the WMI infrastructure to support this
> DHCP query (I believe WINS too). I don't have code to hand.
>
> Yevgen is right in indicating NETSH DHCP ..... (Note this is useful for WINS
> too !!!)
> as this certainly works for Win2k environments, however is NOT an elegant
> solution, albeit you can get the MAC for leases (note you don't get the
> Machine Names though !!!), as you have to trap the results and parse the
> output.... YUCK
> but workable....
>
> An example command line .....
> netsh dhcp server scope 192.168.1.0 show clients
> assuming the scope is 192.168.1.0 that is.....
>
> Clearly you have to know the scope before you make the query so in a big
> environment this may take some extra clever scripting, however that should
> give you the jist of things...
> http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windowsserver2003/proddocs/datacenter/netsh_dhcp.asp
>
> Hope this helps...
> ......
>
> Further to this.....
> NETSH on 2k and 2k3 Server only ! You can't seem to do the same query on XP
> Pro , with even with 2k3 Admin tool kit installed ..... :-(
> Mind you that may be something to do with XPSP2 or something not sure....
>
> Regards
> Greg

Re: Get DHCP lease information by Leena

Leena
Fri Oct 29 03:28:03 CDT 2004

Hi
I m looking for similar kind of information. I want to retrieve default
lease time and maximum lease time from dhcp server programatically. Are these
lease times subnet specific or common for all subnets? Is it possible to get
it programatically? If yes, how?

I went thro the DHCP server management apis given here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhcp/dhcp/dhcp_server_management_api_functions.asp
But i could not figure out which api will be useful. I tried to use
'DhcpGetOptionValue()' to get the value corresponding to option Id 51. But
was unsuccessful (the api returned error code 2). So now I m not sure how to
get the maximum & default lease time. option Id 51 corresponds to lease time.
But is this the default lease time or something else?
Also I want to know how DHCP server is related to domains and DNS servers.
Is it possible to get this information also programatically?

There is something for sure that I m missing/mis-interpreting.

Thanks in advance,
Leena


"Torgeir Bakken (MVP)" wrote:

> Steve wrote:
>
> > I have had need for this type of information also. What I did was to
> > dump the information to a text file then parse the file as needed.
> >
> > dhcpcmd <server_ip> enumclients <scope> -v
> > dhcpcmd 172.25.108.250 enumclients 172.25.100.0 -v >>C:\Working\dhcplease.txt
> >
> > the dhcpcmd is from one of the server resource kits, sorry i do
> > remember whih one, but you can do site search for it at microsoft.
> Hi
>
> Dhcpcmd.exe is in the Windows NT 4.0 Service Pack 4 Support Tools.
>
> How to Use the Dhcpcmd.exe Tool Included with Support Tools
> http://support.microsoft.com/default.aspx?kbid=232213
>
> Download link found here:
>
> Windows NT Service Pack 4.0 Tools Not Included on CD-ROM
> http://support.microsoft.com/default.aspx?kbid=206848
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>

Re: Get DHCP lease information by Ulf

Ulf
Fri Oct 29 06:42:21 CDT 2004

Leena wrote:
> I went thro the DHCP server management apis given here:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhcp/dhcp/dhcp_server_management_api_functions.asp
> But i could not figure out which api will be useful. I tried to use
> 'DhcpGetOptionValue()' to get the value corresponding to option Id
> 51. But was unsuccessful (the api returned error code 2). So now I m

Hi Leena,

How did you managed to use these api functions in you script?
Could you please post you script code?

Regards

Ulf



Re: Get DHCP lease information by Leena

Leena
Mon Nov 01 06:24:02 CST 2004

Hi Ulf,
I think I forgot to mention this. I m using the dhcp server management
functions in a C program.

"Ulf Dornheck Busscher" wrote:

> Leena wrote:
> > I went thro the DHCP server management apis given here:
> >
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhcp/dhcp/dhcp_server_management_api_functions.asp
> > But i could not figure out which api will be useful. I tried to use
> > 'DhcpGetOptionValue()' to get the value corresponding to option Id
> > 51. But was unsuccessful (the api returned error code 2). So now I m
>
> Hi Leena,
>
> How did you managed to use these api functions in you script?
> Could you please post you script code?
>
> Regards
>
> Ulf
>
>
>