• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

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
0
bsharath
Asked:
bsharath
  • 3
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now