?
Solved

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

Posted on 2007-10-11
5
Medium Priority
?
228 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
0
Comment
Question by:bsharath
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20063697
:: * 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
 
LVL 11

Author Comment

by:bsharath
ID: 20063729
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
 
LVL 11

Author Comment

by:bsharath
ID: 20063731
And if i put just 1 ip also it goes on repeatedly showing the same message on the cmd prompt.
0
 
LVL 26

Accepted Solution

by:
Farhan Kazi earned 2000 total points
ID: 20063892
:: * 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
 
LVL 11

Author Comment

by:bsharath
ID: 20067339
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

850 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