Solved

information from Windows dhcp

Posted on 2010-11-18
7
354 Views
Last Modified: 2012-05-10
I need to fetch the current leases from a Windows dhcp server by a script. Or is a kind of dhcp query possible?
0
Comment
Question by:GeologyETH
7 Comments
 
LVL 27

Expert Comment

by:KenMcF
Comment Utility
You can use netsh dhcp server

netsh dhcp server dump

netsh dhcp server show all

then parse the output to the way you want.
0
 
LVL 59

Expert Comment

by:Darius Ghassem
Comment Utility
0
 
LVL 6

Expert Comment

by:ipajones
Comment Utility
Try this in your script:

netsh dhcp server \\dhcpservername show scope scope_name show clients

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Expert Comment

by:Dusan_Bajic
Comment Utility
What ipajones suggested will work, but if you have more than one scope you can run this as a .bat and get them all at once:

For /F "skip=5 delims= " %%a IN ('netsh dhcp server \\dhcpservername show scope') DO (
      if not %%a == Total (if not %%a == Command netsh dhcp server \\dhcpservername scope %%a show clients >> leases.txt)
)
0
 

Author Comment

by:GeologyETH
Comment Utility
Thanks for the answers. I tried "netsh server \\<server> scope x.y.z.c show clients", but this cmd doesn't include the client's name. I need the couple client's name + ip-no.
I modified the script dhcpcheckerv2.2 tow actual situation; it runs, but doesn't mail a result. Not sure what's wrong.
0
 

Author Comment

by:GeologyETH
Comment Utility
The scripts works, but doesn't deliver the client's name + ip-no. Any other idea?
0
 
LVL 7

Accepted Solution

by:
Dusan_Bajic earned 500 total points
Comment Utility
just add option 1 at the end
...... show clients 1 >> leases.txt)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now