Solved

WIreless Mac Address

Posted on 2010-09-06
7
1,692 Views
Last Modified: 2012-05-10
When I run the following VBScript , I get the Mac Address for all the Local Area coonection & Wireless. How can I modify the script just to echo ONLY the Wireless one.

Thanks
Cheers

strComputer = (InputBox(" Computer name for MAC address", "Computer Name"))
If strComputer <> "" Then
strInput = True
End if
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objItem in colItems
Wscript.Echo objItem.MACAddress
Next



0
Comment
Question by:Bianchi928
  • 4
  • 2
7 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 33614176
try:
"Select * From Win32_NetworkAdapter WHERE NetConnectionID LIKE '%Wireless%'"

Resource:
http://msdn.microsoft.com/en-us/library/aa394595%28VS.85%29.aspx
0
 

Author Comment

by:Bianchi928
ID: 33614254
I've changed to and i get an error

Line 9
Char 1
Error 0x80041004
Code 80041004
Source (null)

Line 9 is the "For each


strComputer = (InputBox(" Computer name for MAC address", "Computer Name"))
If strComputer <> "" Then
strInput = True
End if
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapter WHERE NetConnectionID LIKE '%Wireless%'")


For Each objItem in colItems
Wscript.Echo objItem.MACAddress
Next
 
0
 
LVL 8

Accepted Solution

by:
spinzr0 earned 125 total points
ID: 33614480
Here is some code I put together for someone last week.  Give it a shot.
On Error Resume Next



sAdminUserName = "username"

sAdminPassword = "password"

sWiFiQuery = "Select MACAddress from Win32_NetworkAdapterConfiguration WHERE Description Like '%WiFi%' OR Description Like '%Wireless%' OR Description Like '%AGN%'"



Set oComputerObject = CreateObject("WbemScripting.SWbemLocator")

oComputerObject.Security_.ImpersonationLevel = 3

oComputerObject.Security_.AuthenticationLevel = 0



sPC = InputBox(" Computer name for MAC address", "Computer Name")



If Ping(sPC) Then

    Err.Clear

    Set oWMI = oComputerObject.ConnectServer(sPC, "root\cimv2", sPC & "\" & sAdminUserName, sAdminPassword)

    If Err.Number <> 0 Then

        oOutputFile.WriteLine "Can't connect to " & sPC & ".  Please check username/password."

        Err.Clear

    Else

        Set cTemp = oWMI.ExecQuery(sWiFiQuery)

        For Each oItem In cTemp

            Msgbox oItem.MACAddress

            Exit For

        Next

        Set cTemp = Nothing

    End If

Else

    Msgbox sPC & " is not currently pingable."

End If

Set oWMI = Nothing



Set oComputerObject = Nothing

Wscript.Echo "Complete."



Function Ping(sHost)

    Dim oWMILocal, cPings, oPing, iPingResult



    Set oWMILocal = GetObject("winmgmts:\\.\root\cimv2")



    Set cPings = oWMILocal.ExecQuery("Select * from Win32_PingStatus " &_

        "Where Address = '" & sHost & "' AND timeout = 500")

    For Each oPing In cPings

        iPingResult = oPing.StatusCode

        If (iPingResult = 0) Then

            Ping = True

            Exit Function

        Else

            Ping = False

        End If

    Next

End Function

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Bianchi928
ID: 33614523
SPINZR0

ASKED FOR COMPUTER NAME , THEN  DIDN'T DISPLAY ANYTHING, WENT STRAIGHT TO DISPLAY "COMPLETE"
0
 

Author Comment

by:Bianchi928
ID: 33614547
SPINZR0

Oops..don't worry. I typed in the wrong admin password..

Thanks
0
 

Author Closing Comment

by:Bianchi928
ID: 33614548
Perfect
0
 
LVL 8

Expert Comment

by:spinzr0
ID: 33614584
Glad to hear it.  Also, if you change "oOutputFile.WriteLine" to "msgbox" then it will tell you that it failed.  Original code was outputing to a file.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now