We help IT Professionals succeed at work.

Get the results if Reserved or not from a list of ip's or Mac addresses

242 Views
Last Modified: 2010-03-05
Hi,

I have a list of mac addresses and ip addresses .Is there a way that i get the info if they are Reserved or not in the DHCP server.

Regards
Sharath
Comment
Watch Question

Farhan KaziSystems Engineer
CERTIFIED EXPERT
Top Expert 2007

Commented:
:: * This script require 'MACIPList.txt' file from where it will pick IP or MAC address.
:: * MAC address inside 'MACIPList.txt' file shoud be in HEX format (000D5627CE05)
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
:: *** SCRIPT START ***
@ECHO OFF
SETLOCAL EnableDelayedExpansion

IF NOT EXIST MACIPList.txt Goto ShowErr
FOR %%R IN (MACIPList.txt) Do IF %%~zR EQU 0 Goto ShowErr
FOR /F "SKIP=3 TOKENS=2 DELIMS=[]" %%S IN ('NetSh DHCP SHOW SERVER') DO (
      FOR /F %%R IN ('TYPE MACIPList.txt') DO (
            NetSh DHCP SERVER \\%%S DUMP |FIND /I "reservedip"|FIND /I "%%R" >NUL
            IF NOT ERRORLEVEL 1 (ECHO %%R: Reserved) ELSE (ECHO %%R: Not Reserved))
)
GOTO EndScript
:ShowErr
Echo 'MACIPList.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***

Author

Commented:
Farhan as i have 3 DHCP servers in 3 different locations any way to specify the DHCP server address in the script.
The txt file should only have the ip or Mac address right?
I tried from the DHCP server also but shows Not reserved even for Ip's that are reserved

Author

Commented:
And if i put just 1 ip also it goes on repeatedly showing the same message on the cmd prompt.
Systems Engineer
CERTIFIED EXPERT
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks a lot Farhan,

If you remember you gave me a Disabling a user script (All in one).
In the script if the user has a group in the Root Domain it does not remove it.
Can you see if you can help...

 I want a couple of points to be added in it.
1. Logoff the machine whose name is in the Notes box.
2. Get a header on the top of the mail which i get.

If you say yes i shall raise a Q....
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.