AllenAdministrator
(KiX Supporter)
2006-01-09 08:04 AM
RFC - GetIPOptions()

I'm writing this to compliment SetIPOptions() and to address a request from this thread.

It should be able to accept any valid property from Win32_NetworkAdapterConfiguration class, including a few I created (ie StaticIP). Below are a few of the ones I targeted and tested. The function should always return a string.

I could really use someone to try out:
1. A PC with multiple NICs
2. Test it on a remote PC

Suggestions, Comments?


GetIPOptions()
EnumNetworkConnections()


dataspike
(Getting the hang of it)
2006-01-09 09:33 PM
Re: RFC - GetIPOptions()

Dude... you have absolutely no idea how much you rock. That's awesome!

Mart
(KiX Supporter)
2006-01-09 10:24 PM
Re: RFC - GetIPOptions()

Quote:


....
I could really use someone to try out:
1. A PC with multiple NICs
2. Test it on a remote PC
....





Allen,

How far did you get with this already?
Got some servers at work with two and three nic's acting as individual nic's and at least one server with two nic’s teamed.
If still wanted I can let it rip at these servers and at a remote comp when I'm back @work on Wednesday.


AllenAdministrator
(KiX Supporter)
2006-01-09 10:27 PM
Re: RFC - GetIPOptions()

Mart, I would really appreciate it if you could try it out. I don't have the resources, at my finger tips, like I used to.

Mart
(KiX Supporter)
2006-01-09 10:36 PM
Re: RFC - GetIPOptions()

Ok did some messing around at my home comp.

It has 2 "normal" NIC's, one wireless NIC, a Bluetooth thingy and a 1394 connection.
When the BT connection is enabled it gives all 0's as the IP, SN, Def GW, etc....
When the BT connection is disabled it takes the IP's from the first connected NIC (wireless in my case). Is it possible to add the connection name to the output (Local Area Connection, Local Area Connection 2, etc…)? At the first line maybe?

Here is the output.

Quote:


Static Address: False
DHCP Enabled: True
IPaddress/SM: 192.168.2.100,255.255.255.0
IPaddress0/SM: 192.168.2.100,255.255.255.0
IPaddress1/SM:
IPaddress2/SM:
IPaddress3/SM:
DefaultGW: 192.168.2.1
DNS Servers: 192.168.1.1,62.58.50.6
WINS Servers:
DNSSuffix:
DNS Search Order:
DHCP Server: 192.168.2.1
DHCP Lease Obtained: 20060109201156.000000+060
DHCP Lease Expires: 20060119201156.000000+060





Will check against a remote comp and the teamed stuff @work on Wednesday.

[edit]
D#mn. Should pay more attention to what I'm doing. Just logged off our terminal server and clicked reboot in stead off logoff More proof that men can't do two things at the same time. Working from home and kixing.
[/edit]


NTDOCAdministrator
(KiX Master)
2006-01-10 12:05 AM
Re: RFC - GetIPOptions()

Just trying to give folks at work a fresh start

NTDOCAdministrator
(KiX Master)
2006-01-10 12:11 AM
Re: RFC - GetIPOptions()

Worked fine for me both locally and remotely Allen.

Did not test dual nic though.


NTDOCAdministrator
(KiX Master)
2006-01-10 12:27 AM
Re: RFC - GetIPOptions()

Maybe add the MAC in your example too here or when you create and publish UDF.

? " Mac Address: " + getipoptions("Macaddress")
 


AllenAdministrator
(KiX Supporter)
2006-01-10 01:32 AM
Re: RFC - GetIPOptions()

Thanks for testing Doc. Added macaddress to the samples above... but its also listed in the Win32_NetworkAdapterConfiguration properties link.

Thinking about changing IPAddress so that it returns all the IPs associated with the NIC (as WMI does it), and leaving the IPAddress0, IPAddress1, etc, to return the IPAddress and Subnet Mask.


AllenAdministrator
(KiX Supporter)
2006-01-10 09:05 AM
Re: RFC - GetIPOptions()

Mart, I've been trying to think what would cause you to get no results... and I think I now know... because of the loop its displaying what ever the last adapter is, which is likely the BT or 1394 adapter...

I guess I need to think this out a little better.


Mart
(KiX Supporter)
2006-01-11 04:50 PM
Re: RFC - GetIPOptions()

As promised.
Did a test against a remote pc with two teamed Intel 10/100/1000 nics.
MAC of the team is shown as expected.

Quote:


Static Address: True
DHCP Enabled: False
IPaddress/SM: 192.168.1.4,255.255.255.0
IPaddress0/SM: 192.168.1.4,255.255.255.0
IPaddress1/SM:
IPaddress2/SM:
IPaddress3/SM:
DefaultGW: 192.168.1.8
DNS Servers: 192.168.1.1
WINS Servers: 127.0.0.0,127.0.0.0
DNSSuffix:
DNS Search Order:
DHCP Server: 192.168.1.1
DHCP Lease Obtained:
DHCP Lease Expires:
Mac Address: 00:02:B3:BE:2F:DF





Just specifying a value for $remotepc gives an error about undefined variable cause explicit is on and $remotepc is not dimmed I guess.


NTDOCAdministrator
(KiX Master)
2006-01-11 05:28 PM
Re: RFC - GetIPOptions()

No $remotepc is a parameter and should not be dimmed Mart.

Perhaps whatever you called your var when you called the UDF?


Mart
(KiX Supporter)
2006-01-12 09:30 AM
Re: RFC - GetIPOptions()

DOH My bad.
Maybe I did a little typo or so, will see.


AllenAdministrator
(KiX Supporter)
2006-01-27 04:07 PM
Re: RFC - GetIPOptions()

Okay... I might actually have some time this weekend to mess with this.

Mart would you mind running the following code on the box where you had multiple adapters, and post the results?

Code:
 
Break On
$strComputer = "."
$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48)
For each $objItem in $colItems
"ArpAlwaysSourceRoute: " + $objItem.ArpAlwaysSourceRoute ?
"ArpUseEtherSNAP: " + $objItem.ArpUseEtherSNAP ?
"Caption: " + $objItem.Caption ?
"DatabasePath: " + $objItem.DatabasePath ?
"DeadGWDetectEnabled: " + $objItem.DeadGWDetectEnabled ?
For each $Item in $objItem.DefaultIPGateway
"*DefaultIPGateway: " + $Item ?
Next
"DefaultTOS: " + $objItem.DefaultTOS ?
"DefaultTTL: " + $objItem.DefaultTTL ?
"Description: " + $objItem.Description ?
"DHCPEnabled: " + $objItem.DHCPEnabled ?
"DHCPLeaseExpires: " + $objItem.DHCPLeaseExpires ?
"DHCPLeaseObtained: " + $objItem.DHCPLeaseObtained ?
"DHCPServer: " + $objItem.DHCPServer ?
"DNSDomain: " + $objItem.DNSDomain ?
For each $Item in $objItem.DNSDomainSuffixSearchOrder
"*DNSDomainSuffixSearchOrder: " + $Item ?
Next
"DNSEnabledForWINSResolution: " + $objItem.DNSEnabledForWINSResolution ?
"DNSHostName: " + $objItem.DNSHostName ?
For each $Item in $objItem.DNSServerSearchOrder
"*DNSServerSearchOrder: " + $Item ?
Next
"DomainDNSRegistrationEnabled: " + $objItem.DomainDNSRegistrationEnabled ?
"ForwardBufferMemory: " + $objItem.ForwardBufferMemory ?
"FullDNSRegistrationEnabled: " + $objItem.FullDNSRegistrationEnabled ?
For each $Item in $objItem.GatewayCostMetric
"*GatewayCostMetric: " + $Item ?
Next
"IGMPLevel: " + $objItem.IGMPLevel ?
"Index: " + $objItem.Index ?
For each $Item in $objItem.IPAddress
"*IPAddress: " + $Item ?
Next
"IPConnectionMetric: " + $objItem.IPConnectionMetric ?
"IPEnabled: " + $objItem.IPEnabled ?
"IPFilterSecurityEnabled: " + $objItem.IPFilterSecurityEnabled ?
"IPPortSecurityEnabled: " + $objItem.IPPortSecurityEnabled ?
For each $Item in $objItem.IPSecPermitIPProtocols
"*IPSecPermitIPProtocols: " + $Item ?
Next
For each $Item in $objItem.IPSecPermitTCPPorts
"*IPSecPermitTCPPorts: " + $Item ?
Next
For each $Item in $objItem.IPSecPermitUDPPorts
"*IPSecPermitUDPPorts: " + $Item ?
Next
For each $Item in $objItem.IPSubnet
"*IPSubnet: " + $Item ?
Next
"IPUseZeroBroadcast: " + $objItem.IPUseZeroBroadcast ?
"IPXAddress: " + $objItem.IPXAddress ?
"IPXEnabled: " + $objItem.IPXEnabled ?
"IPXFrameType: " + $objItem.IPXFrameType ?
"IPXMediaType: " + $objItem.IPXMediaType ?
"IPXNetworkNumber: " + $objItem.IPXNetworkNumber ?
"IPXVirtualNetNumber: " + $objItem.IPXVirtualNetNumber ?
"KeepAliveInterval: " + $objItem.KeepAliveInterval ?
"KeepAliveTime: " + $objItem.KeepAliveTime ?
"MACAddress: " + $objItem.MACAddress ?
"MTU: " + $objItem.MTU ?
"NumForwardPackets: " + $objItem.NumForwardPackets ?
"PMTUBHDetectEnabled: " + $objItem.PMTUBHDetectEnabled ?
"PMTUDiscoveryEnabled: " + $objItem.PMTUDiscoveryEnabled ?
"ServiceName: " + $objItem.ServiceName ?
"SettingID: " + $objItem.SettingID ?
"TcpipNetbiosOptions: " + $objItem.TcpipNetbiosOptions ?
"TcpMaxConnectRetransmissions: " + $objItem.TcpMaxConnectRetransmissions ?
"TcpMaxDataRetransmissions: " + $objItem.TcpMaxDataRetransmissions ?
"TcpNumConnections: " + $objItem.TcpNumConnections ?
"TcpUseRFC1122UrgentPointer: " + $objItem.TcpUseRFC1122UrgentPointer ?
"TcpWindowSize: " + $objItem.TcpWindowSize ?
"WINSEnableLMHostsLookup: " + $objItem.WINSEnableLMHostsLookup ?
"WINSHostLookupFile: " + $objItem.WINSHostLookupFile ?
"WINSPrimaryServer: " + $objItem.WINSPrimaryServer ?
"WINSScopeID: " + $objItem.WINSScopeID ?
"WINSSecondaryServer: " + $objItem.WINSSecondaryServer ?
?
Next



Mart
(KiX Supporter)
2006-01-27 04:24 PM
Re: RFC - GetIPOptions()

You mean the system with wifi, copper and Bluetooth connections?
Will do when I'm back home tomorrow or on Sunday.


AllenAdministrator
(KiX Supporter)
2006-01-27 08:35 PM
Re: RFC - GetIPOptions()

Yes...that's the one.

Mart
(KiX Supporter)
2006-01-29 01:20 PM
Re: RFC - GetIPOptions()

Here we go.
All connections enabled but not all connected.
You will see the word stuurprogramma in there, that's Dutch for driver.

- 1 WiFi (connected to my accesspoint)
- 2 Copper (enabled but not connected)
- 1 1394 (enabled but not connected)
- 1 Bleutooth (connected to my cell phone)
- 1 Bleutooth modem (part of the bleutooth phone connection, enaled but not connected)

Code:

IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:0C:F6:14:68:99
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName:
SettingID: {67F8C3BC-6B12-4914-9590-C97B1E1E83A8}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000015] Bluetooth Device (Personal Area Network)
DatabasePath:
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: Bluetooth Device (Personal Area Network)
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution:
DNSHostName:
DomainDNSRegistrationEnabled:
ForwardBufferMemory:
FullDNSRegistrationEnabled:
IGMPLevel:
Index: 15
IPConnectionMetric:
IPEnabled: 0
IPFilterSecurityEnabled:
IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress:
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: BthPan
SettingID: {CFF68E80-0891-4044-BBF0-78F3857D7B6F}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000016] Bluetooth stuurprogramma LAN Access Server
DatabasePath: %SystemRoot%\System32\drivers\etc
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
portription: Bluetooth stuurprogramma LAN Access Server - Packet Scheduler Miniport
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution: 0
DNSHostName: challenger
DomainDNSRegistrationEnabled: 0
ForwardBufferMemory:
FullDNSRegistrationEnabled: -1
IGMPLevel:
Index: 16
*IPAddress: 0.0.0.0
IPConnectionMetric: 1
IPEnabled: -1
IPFilterSecurityEnabled: 0
IPPortSecurityEnabled:
*IPSecPermitIPProtocols: 0
*IPSecPermitTCPPorts: 0
*IPSecPermitUDPPorts: 0
*IPSubnet:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:10:60:AF:C0:8F
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: BTWDNDIS
SettingID: {7E9E8D15-9627-403B-8514-4D9652CF6EE5}
TcpipNetbiosOptions: 0
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup: -1
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000017] Packet Scheduler Miniport
DatabasePath:
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: Packet Scheduler Miniport
DHCPEnabled: 0
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution:
DNSHostName:
DomainDNSRegistrationEnabled:
ForwardBufferMemory:
FullDNSRegistrationEnabled:
IGMPLevel:
Index: 17
IPConnectionMetric:
IPEnabled: 0
IPFilterSecurityEnabled:
IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:10:60:AF:C0:8F
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName:
SettingID: {4D806036-BD07-4DE3-9530-8364792A8248}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000018] 1394 Net Adapter
DatabasePath:
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: 1394 Net Adapter
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution:
DNSHostName:
DomainDNSRegistrationEnabled:
ForwardBufferMemory:
FullDNSRegistrationEnabled:
IGMPLevel:
Index: 18
IPConnectionMetric:
IPEnabled: 0
IPFilterSecurityEnabled:
IPPortSecurityEnabled:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 12:6C:11:62:E3:29
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: NIC1394
SettingID: {80677346-6F0E-4A2F-B809-84847B376D66}
TcpipNetbiosOptions:
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup:
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:
;
ArpAlwaysSourceRoute:
ArpUseEtherSNAP:
Caption: [00000019] Microsoft TV/Video Connection
DatabasePath: %SystemRoot%\System32\drivers\etc
DeadGWDetectEnabled:
DefaultTOS:
DefaultTTL:
Description: Intel(R) PRO/100 VM Network Connection - Packet Scheduler Miniport
DHCPEnabled: -1
DHCPLeaseExpires:
DHCPLeaseObtained:
DHCPServer:
DNSDomain:
DNSEnabledForWINSResolution: 0
DNSHostName: challenger
DomainDNSRegistrationEnabled: 0
ForwardBufferMemory:
FullDNSRegistrationEnabled: -1
IGMPLevel:
Index: 19
*IPAddress: 0.0.0.0
IPConnectionMetric: 1
IPEnabled: -1
IPFilterSecurityEnabled: 0
IPPortSecurityEnabled:
*IPSecPermitIPProtocols: 0
*IPSecPermitTCPPorts: 0
*IPSecPermitUDPPorts: 0
*IPSubnet:
IPUseZeroBroadcast:
IPXAddress:
IPXEnabled: 0
IPXFrameType:
IPXMediaType:
IPXNetworkNumber:
IPXVirtualNetNumber:
KeepAliveInterval:
KeepAliveTime:
MACAddress: 00:0B:CD:04:28:D1
MTU:
NumForwardPackets:
PMTUBHDetectEnabled:
PMTUDiscoveryEnabled:
ServiceName: NdisIP
SettingID: {E8645DEA-9366-4AF2-B161-82B3264C54A8}
TcpipNetbiosOptions: 0
TcpMaxConnectRetransmissions:
TcpMaxDataRetransmissions:
TcpNumConnections:
TcpUseRFC1122UrgentPointer:
TcpWindowSize:
WINSEnableLMHostsLookup: -1
WINSHostLookupFile:
WINSPrimaryServer:
WINSScopeID:
WINSSecondaryServer:



Gargoyle
(MM club member)
2006-03-08 11:56 PM
Re: RFC - GetIPOptions()

Ok, I worked with this in regards to this post http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=158386&an=0&page=0#158386 and used this code

Code:

Break On
$=setoption("Wrapateol","on")
$=setoption("Explicit","on")
$=setoption("NoVarsinstrings","on")
$=setoption("NoMacrosinstrings","on")

dim $Server[],$
Open (1,"C:\DNS_Log.TXT",5)

$Server = ;had 41 servers listed here

For Each $ in $Server

;? " Static Address: " + getipoptions("StaticIP")
;? " DHCP Enabled: " + getipoptions("DHCPEnabled")
;? " IPaddress/SM: " + getipoptions("IPAddress")
;? " IPaddress0/SM: " + getipoptions("IPAddress0")
;? " IPaddress1/SM: " + getipoptions("IPAddress1")
;? " IPaddress2/SM: " + getipoptions("IPAddress2")
;? " IPaddress3/SM: " + getipoptions("IPAddress3")
;? " DefaultGW: " + getipoptions("DefaultGW")
Writeline(1," Server: "+$+@CRLF)
Writeline(1," DNS Servers: " + getipoptions("DNSServers",$)+@CRLF)
;? " WINS Servers: " + getipoptions("WINSServers")
;? " DNSSuffix: " + getipoptions("DNSDomain")
;? " DNS Search Order: " + getipoptions("DNSDomainSuffixSearchOrder")
;? " DHCP Server: " + getipoptions("DHCPServer")
;? "DHCP Lease Obtained: " + getipoptions("DHCPLeaseObtained")
;? " DHCP Lease Expires: " + getipoptions("DHCPLeaseExpires")
;? " Mac Address: " + getipoptions("Macaddress")

Next

Close(1)









function GetIPOptions($Setting,optional $remotepc, optional $macaddress)
dim $objWMIService, $colitems, $objnetadapter,$targetadapter,$,$allnics,$counter,$Mask,$SN, $IP, $IPAddress,$toggle
if $remotepc=""
$remotepc="."
endif
if $macaddress=""
$allnics=1
endif
$objWMIService = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2")
if @error
exit @error
endif
$colItems = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=-1")
For Each $objNetAdapter In $colItems
if $macaddress=$objNetAdapter.macaddress or $allnics
select
case instr($setting,"IPAddress")>0
if right($setting,1)="s" or val(right($setting,1))>3 or len($setting)>10
$targetadapter=0
else
$targetadapter=right($setting,1)
endif
$counter=0
for each $IP in $objNetAdapter.IPAddress
if "" + $counter=$targetadapter
$IPAddress=$IP
endif
$counter=$counter+1
next
$counter=0
for each $SN in $objNetAdapter.IPSubnet
if "" + $counter=$targetadapter
$Mask=$SN
endif
$counter=$counter+1
next
$GetIPOptions=$IPAddress
if $mask
$GetIPOptions=$GetIPOptions + "," + $Mask
endif
case $setting="WINSServers"
$GetIPOptions=$objNetAdapter.WINSPrimaryServer
if $objNetAdapter.WINSSecondaryServer<>""
$GetIPOptions=$GetIPOptions + "," + $objNetAdapter.WINSSecondaryServer
endif
case 1
select
case $setting="DefaultGW" or $setting="DefaultGateway" or $setting="Gateway"
$setting="DefaultIPGateway"
case $setting="DNSServers"
$setting="DNSServerSearchOrder"
case $setting="StaticIP" or $setting="Static"
$setting="DHCPEnabled"
$toggle=1
endselect
$=execute("$" + "GetIPOptions=" + "$" + "objNetAdapter." + $setting)
select
case vartype($GetIPOptions)>=8192 ;array
$GetIPOptions=join($GetIPOptions,",")
case vartype($GetIPOptions)=11 ;boolean
if $GetIPOptions=0 - $toggle
$GetIPOptions="False"
else
$GetIPOptions="True"
endif
endselect
endselect
endif
Next
endfunction



Everything worked just fine, however it only reported the last active NIC for systems that had multiple active NIC's


Sealeopard
(KiX Master)
2006-03-09 03:57 AM
Re: RFC - GetIPOptions()

That's by design

The UDF is coded to return the information of the last network interface, if you need to support multiple interfaces, then the UDF needs to be modified to return an array or you need to specify the MAC address of the particular interface you're interested in.


AllenAdministrator
(KiX Supporter)
2006-03-09 04:13 AM
Re: RFC - GetIPOptions()

Yeah guys...we already figured that out... I just haven't had time to mess with this. Sorry... maybe this weekend.

Gargoyle
(MM club member)
2006-03-09 06:58 AM
Re: RFC - GetIPOptions()

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.


AllenAdministrator
(KiX Supporter)
2006-03-09 07:26 AM
Re: RFC - GetIPOptions()

Thanks for testing it... and I'm glad it helped.

Radimus
(KiX Supporter)
2006-03-09 11:36 AM
Re: RFC - GetIPOptions()

I posted some code to Lonk's GetMac() UDF to grab the MAC of an adapter with a given IP

AllenAdministrator
(KiX Supporter)
2006-03-15 05:40 AM
Re: RFC - GetIPOptions()

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}


AllenAdministrator
(KiX Supporter)
2006-03-15 06:53 AM
Re: RFC - GetIPOptions()

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



Gargoyle
(MM club member)
2006-03-15 07:09 AM
Re: RFC - GetIPOptions()

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?


AllenAdministrator
(KiX Supporter)
2006-03-15 07:48 AM
Re: RFC - GetIPOptions()

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" 



Mart
(KiX Supporter)
2006-03-15 09:26 AM
Re: RFC - GetIPOptions()

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:



Gargoyle
(MM club member)
2006-03-15 01:22 PM
Re: RFC - GetIPOptions()

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?


AllenAdministrator
(KiX Supporter)
2006-03-15 04:50 PM
Re: RFC - GetIPOptions()

@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).


Gargoyle
(MM club member)
2006-03-15 06:31 PM
Re: RFC - GetIPOptions()

That was my assumption, and to enum all of them you would just change the If... to for each $name in ...

NTDOCAdministrator
(KiX Master)
2006-03-16 04:33 AM
Re: RFC - GetIPOptions()

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.
 


AllenAdministrator
(KiX Supporter)
2006-03-16 06:46 AM
Re: RFC - GetIPOptions()

Posted Versions:
GetIPOptions()
EnumNetworkConnections()

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


Mart
(KiX Supporter)
2006-03-16 09:41 AM
Re: RFC - GetIPOptions()

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



AllenAdministrator
(KiX Supporter)
2006-03-16 03:36 PM
Re: RFC - GetIPOptions()

Thank you Mart. I've really appreciated your feedback.

Glenn BarnasAdministrator
(KiX Supporter)
2006-03-17 01:23 AM
Re: RFC - GetIPOptions()

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


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

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


Radimus
(KiX Supporter)
2006-04-11 04:03 PM
Re: RFC - GetIPOptions()

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


AllenAdministrator
(KiX Supporter)
2006-04-18 07:31 PM
Re: RFC - GetIPOptions()

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?