[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • 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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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