Re: Multiple MAC Addresses to Output into an Access Table



Again, you are the man. Thank you, this worked perfectly. Sorry for all
the questions I am really starting to get into the scripting side but I
am still fairly new I understand a lot of it but a lot of the If or
multiplex statements are still a bit new to me. I greatly appreciate
all of your help joseomjr. The only other problem I have left with my
inventory script is this same problem but with multiple video cards and
multiple adapter ram. I have no problem gathering one of the cards, but
when it comes to both videos cards and their ram I have been
unsuccessful. I have tried duplicating (give or take) the code for the
ips but I haven't been able to pull it off.

For Each objIP In colIP
If Not IsNull(objIP.IPAddress)Then
For i = LBound(objIP.IPAddress) To
UBound(objIP.IPAddress)
If Not objIP.IPAddress(i) = "0.0.0.0" Then
If i2 = 0 Then
IPAddress1 = objIP.IPAddress(0)
MACAddr1 = objIP.MACAddress
recADO.Fields("IP1").Value = IPAddress1
recADO.Fields("MAC1").Value = MACAddr1
i2 = i2 + 1
ElseIf i2 = 1 Then
IPAddress2 = objIP.IPAddress(0)
MACAddr2 = objIP.MACAddress
recADO.Fields("IP2").Value = IPAddress2
recADO.Fields("MAC2").Value = MACAddr2
i2 = i2 + 1
End If
End If
Next
End If
Next


joseomjr@xxxxxxxxx wrote:
how about this? watch out for the line wrap

Option Explicit
'On Error Resume Next

Dim strComputer, objWMIService, IPConfigSet, IPConfig, i, i2
Dim IPAddress1, IPAddress2, MACAddr1, MACAddr2

strComputer = "."
i2 = 0

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer _
& "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery("Select * from " _
& "Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each IPConfig In IPConfigSet
If Not IsNull(IPConfig.IPAddress)Then
For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
If Not IPConfig.IPAddress(i) = "0.0.0.0" Then
If i2 = 0 Then
IPAddress1 = IPConfig.IPAddress(0)
MACAddr1 = IPConfig.MACAddress
WScript.Echo "IPAddress1: " & IPAddress1
WScript.Echo "MACAddress1: " & MACAddr1
i2 = i2 + 1
ElseIf i2 = 1 Then
IPAddress2 = IPConfig.IPAddress(0)
MACAddr2 = IPConfig.MACAddress
WScript.Echo "IPAddress2: " & IPAddress2
WScript.Echo "MACAddress2: " & IPConfig.MACAddress
i2 = i2 + 1
End If
End If
Next
End If
Next
snivitzo wrote:
How would I go about having it output the matching mac address to the
adapter the ip is being pulled from. In my table I would have IP1 MAC1
IP2 MAC2 ect....?

Thank you in advance for anyone's help with this issue.

snivitzo wrote:
You make it happen! Worked perfect, thanks for your help. If anyone
knows any other ways of doing this I'm sure it may help some other
people down the line. For writing to Access this worked like a charm.


joseomjr@xxxxxxxxx wrote:
how about something like this. you're able to split the ip's into two
seperate variables. may not be the most elegant.

Option Explicit
'On Error Resume Next

Dim strComputer, objWMIService, IPConfigSet, IPConfig, i, i2
Dim IPAddress1, IPAddress2

strComputer = "."
i2 = 0

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where
IPEnabled=TRUE")

For Each IPConfig In IPConfigSet
If Not IsNull(IPConfig.IPAddress)Then
For i = LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
If Not IPConfig.IPAddress(i) = "0.0.0.0" Then
If i2 = 0 Then
IPAddress1 = IPConfig.IPAddress(0)
WScript.Echo "IPAddress1: " & IPAddress1
i2 = i2 + 1
ElseIf i2 = 1 Then
IPAddress2 = IPConfig.IPAddress(0)
WScript.Echo "IPAddress2: " &IPAddress2
i2 = i2 + 1
End If
End If
Next
End If
Next
snivitzo wrote:
I have been using the following script to gather IP information.
Unfortunately now I need a script that can pull and separate the wired
and wireless ip addresses for a local machine. When I implement the
following script to write to an access database the database will only
capture one of the two ip address, or it will use two rows to repeat
the system information to display both IP address. I have used all the
tricks I know and I have decided to seek help! If anyone has any input,
it would be greatly appreciated. The temporary fix I have been using is
to delimit the ips with a space, unfortunately I do need them to
displayed in different fields for certain reports I will run from the
database.

So to recap: I need a script that can write both the IP Physical and
the IP Wireless address to a table in two different columns not rows.

If you need any information from me please ask, I am very interested in
a solution to this problem.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration Where
IPEnabled=TRUE")

For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next

.



Relevant Pages


Loading