RSS

Script to get all active msdhcp client leases using netsh

01 Jun

Here is a quick batch file you can use to get active leases of all scopes for a list of ms dhcp servers. Assuming that you already done a dump using “netsh dhcp server \\host dump” to a file called dhcp_dumps.txt:

find .\dhcp_dumps.txt /i "add scope" | _
find /i "dhcp server" > .\ts.txt
del /q .\getac.txt

for /f "tokens=1,2,3,4,5,6,7 delims= " %%a in (.\ts.txt) do _
@echo dhcp server %%c scope %%f show clients 1 >> getac.txt

netsh -f .\getac.txt > .\ac_list.txt

Note: Updated with a better script

Also note: _ is used as a wrapper for the blog, its not used in the actual script

Advertisements
 
Leave a comment

Posted by on June 1, 2011 in Scripts, Windows, Windows CMD

 

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: