Prev: Does WMI Provide NIC Speed/Duplex Info Somewhere?
Next: error 80041004: Provider Failure in accessing CD-Rom
From: David Doumani on 2 Apr 2005 21:10 Ok, I finally got the IP addresses for a machine to list out via the following code... Next 'IP Address Wscript.Echo " " Wscript.Echo " " Wscript.Echo " IP Addresses " Wscript.Echo " " Wscript.Echo " " Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration ") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) WScript.Echo " IP ADDRESS: " & IPConfig.IPAddress(i) Next End If Next I would now like to get the MAC Addres and I have tried selecing * from the WIn32_NetworkAdapterConfig and listing the mac's but I get all the macs for all the nics, even if they have no IP associated to them... I would like my output to be IPADDRESS: 0.0.0.0. MAC ADDRESS: xxxxxxxxxxx Any suggestions on how to change the above code to reflect that?
From: Ato Bisda on 3 Apr 2005 22:59
Just add MACAddress in your WQL and Wscript.echo as in the following: Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress, MACAddress from Win32_NetworkAdapterConfiguration ") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) WScript.Echo " IP ADDRESS: " & IPConfig.IPAddress(i), "MAC ADDRESS:" IPConfig.MACAddress Next End If Next "David Doumani" <ddoumani(a)doumaniweb.com> wrote in message news:e6DwXJ$NFHA.1396(a)TK2MSFTNGP10.phx.gbl... > Ok, I finally got the IP addresses for a machine to list out via the > following code... > > Next > > 'IP Address > Wscript.Echo " " > Wscript.Echo " " > Wscript.Echo " IP Addresses " > Wscript.Echo " " > Wscript.Echo " " > Set IPConfigSet = objWMIService.ExecQuery("Select IPAddress from > Win32_NetworkAdapterConfiguration ") > For Each IPConfig in IPConfigSet > If Not IsNull(IPConfig.IPAddress) Then > For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) > WScript.Echo " IP ADDRESS: " & IPConfig.IPAddress(i) > Next > End If > Next > > > I would now like to get the MAC Addres and I have tried selecing * from the > WIn32_NetworkAdapterConfig and listing the mac's but I get all the macs for > all the nics, even if they have no IP associated to them... I would like my > output to be IPADDRESS: 0.0.0.0. MAC ADDRESS: xxxxxxxxxxx > > Any suggestions on how to change the above code to reflect that? > > |