Get ip address and Mac address from machines when switched off also.

Hi,

Get ip address and Mac address from machines when switched off also.
I have the below solution from AmazingTech

FOR /f %a in (machine.lst) do FOR /f "tokens=2 delims=[]" %%b in ('ping -n 1 -w 100 %%a ^| find /i "pinging"') do echo %%a,%%b>>MachineIP.CSV

I need a option of getting the Mac  address also in the next colum along with ip address.

Regards
Sharath

LVL 11
bsharathAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AmazingTechCommented:
If you have WINS we can get the MAC from there only if the machine is on.
0
AmazingTechCommented:
MAC will be blank if the machine is off.
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f %%a in (machine.lst) do FOR /f "tokens=2 delims=[]" %%b in ('ping -n 1 -w 100 %%a ^| find /i "pinging"') do (
    SET MAC=
    FOR /f "Tokens=3 Delims== " %%c in ('nbtstat -a %%a ^| find /i "MAC Address"') DO SET MAC=%%c
    echo %%a,%%b,!MAC!>>MachineIPMAC.CSV
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bsharathAuthor Commented:
AT cant we get the Mac if the machine is OFf from the DHCP servers
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

bsharathAuthor Commented:
AT cant we get the Mac if the machine is OFf from the DHCP servers
0
AmazingTechCommented:
Hmm... What DHCP service are you using? CISCO? MS Server 2003? Something else?
0
bsharathAuthor Commented:
Windows 2003 Server
0
bsharathAuthor Commented:
Windows 2003 Server
0
bsharathAuthor Commented:
Hi AT any views...
0
AmazingTechCommented:
Sorry I don't have Windows DHCP. I was going to spin one up but just haven't had the chance yet. Maybe if you could do a dump and post the file up here I can work with the output.

Please mask any personalized info. Like MAC address might show up as 08:02:21:AE:0E:88 change it to XX:XX:XX:XX:XX:XX

Keep the formatting the same I don't need to see your specific info.

netsh dhcp server {ServerName} dump > DHCPDUMP.TXT
netsh dhcp server {ServerName} show > DHCPSHOW.TXT
0
bsharathAuthor Commented:
AT
Is there any specific data you need from this output. As this is a very long output that comes out...
0
bsharathAuthor Commented:
AT
Is there any specific data you need from this output. As this is a very long output that comes out...
0
AmazingTechCommented:
Just need to know where MAC addresses are positioned in the file and all the other lines before and after so I can see how to get just the info you want. A couple computers will do.
0
bsharathAuthor Commented:
Hi AT sorry for the delay i getting back

This command gets some data and just the reservations details
netsh dhcp server {ServerName} dump > DHCPDUMP.TXT

This command does not get anything i tried with show all and get just the stats of how many ip's are there how many free etc
netsh dhcp server {ServerName} show > DHCPSHOW.TXT
0
bsharathAuthor Commented:
Hi AT sorry for the delay i getting back

This command gets some data and just the reservations details
netsh dhcp server {ServerName} dump > DHCPDUMP.TXT

This command does not get anything i tried with show all and get just the stats of how many ip's are there how many free etc
netsh dhcp server {ServerName} show > DHCPSHOW.TXT
0
AmazingTechCommented:
Hmm... I believe these commands are from one of tigermatt's solutions to you. Unfortunately I can't run them here. So there are no MAC addresses in these dumps?
0
bsharathAuthor Commented:
There are but not of leased ip's but of just reserved ip's
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

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.