#154803 - 2006-03-09 11:36 AM
Re: RFC - GetIPOptions()
|
Radimus
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
|
Top
|
|
|
|
#154805 - 2006-03-15 06:53 AM
Re: RFC - GetIPOptions()
|
Allen
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
|
|
|
|
#154807 - 2006-03-15 07:48 AM
Re: RFC - GetIPOptions()
|
Allen
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
|
|
|
|
#154810 - 2006-03-15 04:50 PM
Re: RFC - GetIPOptions()
|
Allen
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
|
|
|
|
#154812 - 2006-03-16 04:33 AM
Re: RFC - GetIPOptions()
|
NTDOC
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
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
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
|
|
|
|
#154817 - 2006-04-11 01:42 PM
Re: RFC - GetIPOptions()
|
AstaaLavista
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
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
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 628 anonymous users online.
|
|
|