Excel Macro that can query colum "Q" Machine name and check the NT login in colum "L" and tell me if the user is in the Administrator group in the local machine "Yes" or "No"

hi,

Excel Macro that can query colum "Q" Machine name and check the NT login in colum "L" and tell me if the user is in the Administrator group in the local machine "Yes" or "No"

So i know if the machine is really being used by that person that my records show.

Want the results in colum "CC"

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
Sharath, try this code.

Regards,

Rob.
Sub Check_Local_Admin_Group()
    For intRow = 2 To Cells(65536, "Q").End(xlUp).Row
        strComputer = Trim(Cells(intRow, "Q").Value)
        strUser = Trim(Cells(intRow, "L").Value)
        If strComputer <> "" And strUser <> "" Then
            If Cells(intRow, "CC").Value = "" Then
                If Ping(strComputer) = True Then
                    On Error Resume Next
                    Set objAdminGroup = GetObject("WinNT://" & strComputer & "/Administrators")
                    If Err.Number = 0 Then
                        On Error GoTo 0
                        strMember = "No"
                        For Each objMember In objAdminGroup.Members
                            If InStr(LCase(objMember.adsPath), LCase(strUser)) > 0 Then
                                strMember = "Yes"
                                Exit For
                            End If
                        Next
                        Cells(intRow, "CC").Value = strMember
                    Else
                        Err.Clear
                        On Error GoTo 0
                    End If
                    Set objWMIService = Nothing
                End If
            End If
        End If
    Next
End Sub
 
Function Ping(strComputer)
    Dim objShell, boolCode
    Set objShell = CreateObject("WScript.Shell")
    boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
    If boolCode = 0 Then
        Ping = True
    Else
        Ping = False
    End If
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bsharathAuthor Commented:
Thank U Rob just running a full Domain scan... :-)
Any help on the mail i sent you and this
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_23880366.html
0
bsharathAuthor Commented:
Thank U Rob just running a full Domain scan... :-)
Any help on the mail i sent you and this
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_23880366.html
0
bsharathAuthor Commented:
Thank U Rob works perfect...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.