Page 2 of 2 <12
Topic Options
#154801 - 2006-03-09 06:58 AM Re: RFC - GetIPOptions()
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Sorry for the repeat of information. This place is so busy it is easy to lose track.

But it saved me a huge amount of time, so for that I am highly appreciative.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#154802 - 2006-03-09 07:26 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Thanks for testing it... and I'm glad it helped.
Top
#154803 - 2006-03-09 11:36 AM Re: RFC - GetIPOptions()
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
I posted some code to Lonk's GetMac() UDF to grab the MAC of an adapter with a given IP
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#154804 - 2006-03-15 05:40 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
I finally took a few minutes to look at this... as it turned out, I have not changed the GetIPOption() function, but instead added some functionality to EnumNetworkConnections to now allow you to not only get the Connection Name, but also the associated MACAddress and/or the Network Adapter Name.

Anyone willing to give this new code a shot on a remote computer?

Comments?

{Edit: Code Removed}

Top
#154805 - 2006-03-15 06:53 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
I believe this would be the code to test a remotepc...

Code:
 
$remotepc="ComputerName"
for each $nc in Enumnetworkconnections(3,$remotepc)
$ConnectionName=split($nc,",")[0]
$MACAddress=split($nc,",")[1]
$AdapterName=split($nc,",")[2]
if $ConnectionName="Local Area Connection"
? " Connection Name: " + $connectionname
? " MACAddress: " + $MACAddress
? " Adapter Name: " + $AdapterName
? " Mac Address: " + getipoptions("Macaddress",$remotepc,$macaddress)
? " Static Address: " + getipoptions("StaticIP",$remotepc,$macaddress)
? " DHCP Enabled: " + getipoptions("DHCPEnabled",$remotepc,$macaddress)
? " IPaddress/SM: " + getipoptions("IPAddress",$remotepc,$macaddress)
? " IPaddress0/SM: " + getipoptions("IPAddress0",$remotepc,$macaddress)
? " IPaddress1/SM: " + getipoptions("IPAddress1",$remotepc,$macaddress)
? " IPaddress2/SM: " + getipoptions("IPAddress2",$remotepc,$macaddress)
? " IPaddress3/SM: " + getipoptions("IPAddress3",$remotepc,$macaddress)
? " DefaultGW: " + getipoptions("DefaultGW",$remotepc,$macaddress)
? " DNS Servers: " + getipoptions("DNSServers",$remotepc,$macaddress)
? " WINS Servers: " + getipoptions("WINSServers",$remotepc,$macaddress)
? " DNSSuffix: " + getipoptions("DNSDomain",$remotepc,$macaddress)
? " DNS Search Order: " + getipoptions("DNSDomainSuffixSearchOrder",$remotepc,$macaddress)
? " DHCP Server: " + getipoptions("DHCPServer",$remotepc,$macaddress)
? "DHCP Lease Obtained: " + getipoptions("DHCPLeaseObtained",$remotepc,$macaddress)
? " DHCP Lease Expires: " + getipoptions("DHCPLeaseExpires",$remotepc,$macaddress)
endif
next


Top
#154806 - 2006-03-15 07:09 AM Re: RFC - GetIPOptions()
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
This line here ..
Quote:

if $ConnectionName="Local Area Connection"




That is quite limiting for those of us that rename our connections. In my multi nic machines we rename all of the connections as to what the function they are performing ex: Primary, NLB, Cluster, iSCSI etc.

Or am I just reading it incorrectly?
_________________________
Today is the tomorrow you worried about yesterday.

Top
#154807 - 2006-03-15 07:48 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
That's the beauty of using Enumnetworkconnections... it will return those names, and if you know what it is, change it.

Code:
 if $ConnectionName="Primary" 


Top
#154808 - 2006-03-15 09:26 AM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
LOL This is all I get on a remote computer. All data is the data of my local NIC not the remote one.

Code:


Connection Name: Local Area Connection
MACAddress: 00:11:11:27:68:F9
Adapter Name: Broadcom NetXtreme 57xx Gigabit Controller
Mac Address:
Static Address:
DHCP Enabled:
IPaddress/SM:
IPaddress0/SM:
IPaddress1/SM:
IPaddress2/SM:
IPaddress3/SM:
DefaultGW:
DNS Servers:
WINS Servers:
DNSSuffix:
DNS Search Order:
DHCP Server:
DHCP Lease Obtained:
DHCP Lease Expires:

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#154809 - 2006-03-15 01:22 PM Re: RFC - GetIPOptions()
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Quote:

and if you know what it is, change it


.
Using that logic, would it be possible to build an array from the enumnetworkconnections() that has all of the connections in it, and then spit out the information for each one?
_________________________
Today is the tomorrow you worried about yesterday.

Top
#154810 - 2006-03-15 04:50 PM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
@Mart... it would help me if you showed what code you used for those results.
{edit... I just realized I posted an older version of EnumNetworkConnections... }
{edit2: Updated post above with newer ENC() }

@Garg... look at the code closely... I'll be glad to help, but... (It already does this).


Edited by Allen (2006-03-15 05:06 PM)

Top
#154811 - 2006-03-15 06:31 PM Re: RFC - GetIPOptions()
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
That was my assumption, and to enum all of them you would just change the If... to for each $name in ...
_________________________
Today is the tomorrow you worried about yesterday.

Top
#154812 - 2006-03-16 04:33 AM Re: RFC - GetIPOptions()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11624
Loc: CA
Allen,

The code works fine for me. Though as mentioned you can't assume the name of the NIC and use that, otherwise it may not be true and you will have no results.

If the Admin knows the name(s) of his/her NICs then fine, otherwise maybe just show as an EXAMPLE in the UDF Header a method to remotely gather the names of the NICS. Then it's up to the Admin to script and get the information he/she wants.

Testing against Glenn's code shows that his UDF
NICINFO
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=150379

Is about .2 to .4 seconds faster running, but it does not return the MAC address. He could add the WMI code to get it, but then I'm sure speed wise both solutions would be similar in speed.

The nice thing about Glenn's approach is that it does not require WMI - though that is less and less of an issue for most Administrators.
 

Top
#154813 - 2006-03-16 06:46 AM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Posted Versions:
GetIPOptions()
EnumNetworkConnections()

As requested I changed one of the GetIPOptions examples so that it displays all the Connections with its settings.

Top
#154814 - 2006-03-16 09:41 AM Re: RFC - GetIPOptions()
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Allen,

As requested in your PM.
It now seems to work OK on a remote machine. Should I give it a go at my home system with the dual copper, BT, WiFi, Firewire connections also?

Results when ran against a remote pc:
Code:

Connection Name: Local Area Connection
MACAddress: 00:07:E9:D2:80:FA
Adapter Name: Intel(R) PRO/100 VE Network Connection
Mac Address: 00:07:E9:D2:80:FA
Static Address: False
DHCP Enabled: True
IPaddress/SM: 192.168.1.10,255.255.255.0
IPaddress0/SM: 192.168.1.10,255.255.255.0
IPaddress1/SM:
IPaddress2/SM:
IPaddress3/SM:
DefaultGW: 192.168.1.8
DNS Servers: 192.168.1.1,192.168.1.2
WINS Servers:
DNSSuffix: [removed for security reasons]
DNS Search Order:
DHCP Server: 192.168.1.1
DHCP Lease Obtained: 20060315090050.000000+060
DHCP Lease Expires: 20060329100050.000000+120



Code used:

Code:

Call @SCRIPTDIR + "\GetIPOptions().udf"
Call @SCRIPTDIR + "\EnumNetworkConnections().udf"

$remotepc="some remote pc"
For Each $nc in Enumnetworkconnections(3,$remotepc)
$ConnectionName=Split($nc,",")[0]
$MACAddress=Split($nc,",")[1]
$AdapterName=Split($nc,",")[2]
If $ConnectionName="Local Area Connection"
? " Connection Name: " + $connectionname
? " MACAddress: " + $MACAddress
? " Adapter Name: " + $AdapterName
? " Mac Address: " + getipoptions("Macaddress",$remotepc,$macaddress)
? " Static Address: " + getipoptions("StaticIP",$remotepc,$macaddress)
? " DHCP Enabled: " + getipoptions("DHCPEnabled",$remotepc,$macaddress)
? " IPaddress/SM: " + getipoptions("IPAddress",$remotepc,$macaddress)
? " IPaddress0/SM: " + getipoptions("IPAddress0",$remotepc,$macaddress)
? " IPaddress1/SM: " + getipoptions("IPAddress1",$remotepc,$macaddress)
? " IPaddress2/SM: " + getipoptions("IPAddress2",$remotepc,$macaddress)
? " IPaddress3/SM: " + getipoptions("IPAddress3",$remotepc,$macaddress)
? " DefaultGW: " + getipoptions("DefaultGW",$remotepc,$macaddress)
? " DNS Servers: " + getipoptions("DNSServers",$remotepc,$macaddress)
? " WINS Servers: " + getipoptions("WINSServers",$remotepc,$macaddress)
? " DNSSuffix: " + getipoptions("DNSDomain",$remotepc,$macaddress)
? " DNS Search Order: " + getipoptions("DNSDomainSuffixSearchOrder",$remotepc,$macaddress)
? " DHCP Server: " + getipoptions("DHCPServer",$remotepc,$macaddress)
? "DHCP Lease Obtained: " + getipoptions("DHCPLeaseObtained",$remotepc,$macaddress)
? " DHCP Lease Expires: " + getipoptions("DHCPLeaseExpires",$remotepc,$macaddress)
EndIf
Next

sleep 25



Edited by Mart (2006-03-16 09:44 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#154815 - 2006-03-16 03:36 PM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Thank you Mart. I've really appreciated your feedback.
Top
#154816 - 2006-03-17 01:23 AM Re: RFC - GetIPOptions()
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Allen - catch me on MSN when you get a chance.. I've tested this on / against several machines in my home net, and also compared it against the NicInfo UDF I wrote some time ago. I don't want to post all the info here, as some of it should not be made "globally" public.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#154817 - 2006-04-11 01:42 PM Re: RFC - GetIPOptions()
AstaaLavista Offline
Starting to like KiXtart

Registered: 2005-08-11
Posts: 111
Loc: Gujarat, India.
Thanks Allen for this wonderful script.
Some time back i had posted a help request for updating static I.P.s of various machines remotely.
this script has solved my purpose......
Great

Top
#154818 - 2006-04-11 04:03 PM Re: RFC - GetIPOptions()
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Enumnetworkconnections().. nice, real nice

It would be nice if there was an option to return just the active adapter...

Onboard LAN,3Com 3C920 Integrated Fast Ethernet Controller (3C905C-TX Compatible)
Docking Station,3Com 3C905TX-based Ethernet Adapter (Generic)

Where, in this case, the "Docking Station" adapter is currently active

Additionally, the optional Mode, could be &
001 = 1 = Connection Name
010 = 2 = MAC
100 = 4 = Adapter Name
110 = 6 = MAC,Adapter Name
111 = 7 = Connection,MAC,Adapter Name
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#154819 - 2006-04-18 07:31 PM Re: RFC - GetIPOptions()
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
The only reason I included the connection name was for backward compatibility with my old UDF. I guess I kind of liked having the Name of the connection with the other properties too. But I guess we could change this thing around a bit and give it a differnet name if you like?
Top
Page 2 of 2 <12


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 628 anonymous users online.
Newest Members
Raoul, Timothy, Jojo67, MaikSimon, kvn317
17875 Registered Users

Generated in 0.078 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org