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

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
LVL 11
bsharathAsked:
Who is Participating?
 
Farhan KaziConnect With a Mentor Systems EngineerCommented:
:: * This script require 'DHCPServers.txt' file from where it will DHCP Server's pick Name or IP address.
:: * 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
IF NOT EXIST DHCPServers.txt Goto ShowErr
FOR %%R IN (DHCPServers.txt) Do IF %%~zR EQU 0 Goto ShowErr
FOR /F %%S IN ('TYPE DHCPServers.txt') 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 or DHCPServers.txt' file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
0
 
Farhan KaziSystems EngineerCommented:
:: * 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 ***
0
 
bsharathAuthor 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
0
 
bsharathAuthor Commented:
And if i put just 1 ip also it goes on repeatedly showing the same message on the cmd prompt.
0
 
bsharathAuthor 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....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.